I need to run *part* of standard input through compress, after
inspecting the remainder. (It's for a weird newsfeed -- boring
details on request.) While I could pipe it through a subprocess,
that's a rather complicated dance, and I thought there ought to be a
way to pass the properly-positioned file descriptor to compress. It
sure *looks* as though I should be able to do something like this:
flags = fcntl(fileno(stdin),F_GETFD);
flags &= !FD_CLOEXEC;
fcntl(fileno(stdin),F_SETFD,flags);
flags = fcntl(fileno(stdout),F_GETFD);
flags &= !FD_CLOEXEC;
fcntl(fileno(stdout),F_SETFD,flags);
if (execlp(DECOMPRESSOR,DECOMPRESSOR,"-d",NULL))
perror("execlp");
but although compress is launched successfully, it complains about
unexpected end of input. strace shows the first read() returning
zero. What did I miss?
(The kernel is Linux 2.2.17, libc is GNU libc 2.2.3 .)
--
Make a good day.