문제

The problem with sendfile is it can't copy two text files using the file fds. The error is EINVAL. // Descriptor is not valid or locked, or an mmap()-like operation is not available for in_fd.

What does this really mean ?

From the man page of sendfile ( man sendfile ) I found this statement. Not sure if it will work to copy two regular files or not.

Presently (Linux 2.6.9): in_fd, must correspond to a file which supports mmap()-like operations (i.e., it cannot be a socket); and out_fd must refer to a socket.

   Applications may wish to fall back to read(2)/write(2) in the case where sendfile() fails with EINVAL or ENOSYS.
도움이 되었습니까?

해결책

The idea behind sendfile() is to quickly send a file over a socket (think web servers). Regular files can be mmap()ed, but are not sockets, so it's blowing up when you hand it a regular file as the destination.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top