Re: execl bug?

From: Dan Nelson (dnelson_at_allantgroup.com)
Date: 12/30/04

  • Next message: Christopher Weimann: "Re: execl bug?"
    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"
    

  • Next message: Christopher Weimann: "Re: execl bug?"

    Relevant Pages

    • RH AS3.0 Beta - office and other apps freeze up opening docs., spreadsheets
      ... The O/S I am using is Redhat Enterprise Linux AS3.0 Beta, ... but works if I deinstall and reinstall it ... I have the home partition on an extractable disk, ... When I try to open star office 5.2 now, it opens fine, but I know I will ...
      (RedHat)
    • execl bug?
      ... For example the program below opens a file, reads a line, rewinds ... then uses execl to call "cat -" which ought to send the file to stdout. ... I tried it on a Redhat box to see if everything behaves the same. ... int argc; ...
      (freebsd-hackers)
    • [kde-linux] how to configure kde and qt
      ... I'm using kdevelop 2.1 on redhat 9 ... but still it opens qt-3.1 ... Archives: http://lists.kde.org/. ...
      (KDE)