Re: execl bug?
From: Dan Nelson (dnelson_at_allantgroup.com)
Date: 12/30/04
- Previous message: Christopher Weimann: "execl bug?"
- In reply to: Christopher Weimann: "execl bug?"
- Next in thread: Christopher Weimann: "Re: execl bug?"
- Reply: Christopher Weimann: "Re: execl bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 29 Dec 2004 18:10:43 -0600 To: Christopher Weimann <csw@k12hq.com>
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 dnelson@allantgroup.com _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
- Previous message: Christopher Weimann: "execl bug?"
- In reply to: Christopher Weimann: "execl bug?"
- Next in thread: Christopher Weimann: "Re: execl bug?"
- Reply: Christopher Weimann: "Re: execl bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|