write() in sys/uio.h returns -1
I'm using Ubuntu Server 9.10 AMD Phenom 2 cpu g++ (Ubuntu 4.4.1-4ubuntu9) 4.4.1
trying to run the application pftp-shit v 1.11, which runs successfully until the remote file list is going to be saved (into .pftp//pftpfxp--).
The following code in tcp.cc is executed successfully:
int outfile_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY)
which returns a file descriptor int (in my case 6) - name is a char array containing a valid path to my file which successfully i created. and successfully running:
fchmod(outfile_fd, S_IRUSR | S_IWUSR);
and
access(name, W_OK)
The issue occurs during running the function (from sys/uio.h)
write(outfile_fd, this->control_buffer, read_length)
which returns -1. -1 is of returned if nothing was written and otherwise a non-negative integer is returned which is equal to the number of bytes written.
Anyone h开发者_运维知识库aving a clue how I can get the write function to work?
On error, -1 is returned, and errno is set appropriately.
Perhaps errno
could give you some hints about what's wrong.
write(outfile_fd, this->control_buffer, read_length);
Does read_length
contain correct number of bytes to be written?
Are the directory and file definitely writable by the user attempting the write? Maybe try running it in /tmp just as a test.
精彩评论