Reputation: 4750
I'm trying to compile some C code on Cygwin which needs the sendfile.h. When I try to compile, it gives me
fatal error: sys/sendfile.h: No such file or directory
compilation terminated.
How do I solve this? Will I have to move to a linux platform? I have gcc4.5 installed on Cygwin.
Upvotes: 1
Views: 2170
Reputation: 11
I removed
#include <sys/sendfile.h>
and rewrite
sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
to
read(read_fd, &offset, stat_buf.st_size);
write(write_fd, &offset, stat_buf.st_size);
and it works fine. Thanks.
Upvotes: 1
Reputation: 17312
Like the comment mentioned, sendfile
is not POSIX, however, from the man page of
sendfile(2)
sendfile() copies data between one file descriptor and another. Because this copying is done within the kernel, sendfile() is more efficient than the combination of read(2) and write(2), which would require transferring data to and from user space.
Which means it's basically a read()
followed by a write()
, so it would be relatively easy to implement it yourself.
Upvotes: 2