In the last episode (Dec 29), Christopher Weimann said: > It seems that the open handle is carried through and usable by the > child program unless the parent has done something to move the file > pointer. For example the program below (tst.c) opens a file, reads a > line, rewinds then uses execl to call "cat -" which ought to send the > file to stdout. > > I thought I must be misunderstanding how execl is supposed to work so > I tried it on a Redhat box to see if everything behaves the same. It > doesn't. On Redhat the file is displayed just as I would expect.
I think your problem here is with rewind(). There's nothing that says it has to change the underlying filedescriptor; FreeBSD's fseek code knows that the beginning of the file is still within its stdio buffer, so it simply resets the seek offset in the FILE* back to zero. See the code in /usr/src/lib/libc/stdio/fseek.c . Replacing your rewind() with an lseek(0,0,SEEK_SET) makes the program work. -- Dan Nelson [EMAIL PROTECTED] _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"