This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: fork() + file descriptor bug in 1.7.27(0.271/5/3) 2013-12-09 11:54
- From: Lord Laraby <lord dot laraby at gmail dot com>
- To: Cygwin Mailing List <cygwin at cygwin dot com>
- Date: Tue, 14 Jan 2014 23:53:18 -0500
- Subject: Re: fork() + file descriptor bug in 1.7.27(0.271/5/3) 2013-12-09 11:54
- Authentication-results: sourceware.org; auth=none
- References: <831845 dot 98759 dot bm at smtp116 dot sbc dot mail dot ne1 dot yahoo dot com> <52D55D96 dot 8070407 at redhat dot com> <946338 dot 89157 dot bm at smtp116 dot sbc dot mail dot ne1 dot yahoo dot com>
My two cents say, since the child is not referencing 'fp' at all,
there is no violation of the POSIX semantics in this situation. It
actually does seem, however, that the fork is closing, or at least
forgetting the stdio file position of, fp when it forks. A possible
memory corruption during fork from which fgets can not recover?
On Tue, Jan 14, 2014 at 10:50 AM, <tednolan@bellsouth.net> wrote:
> In message <52D55D96.8070407@redhat.com>you write:
>>
>>Your program may be violating POSIX, which would trigger undefined behavior.
>>
>>Quoting POSIX:
>> pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_05
>>
>
> [long quote elided]
>
> Yikes! That's pretty impenatrable. And if it says what I think it says,
> it seems to violate the way I've understood Unix fork() and how fds
> (and stdio buffers) are inherited since forever.
>
> However..
>
> Do I understand that to say that if the first thing my child does is
>
> fclose(fp);
>
> everything should be hunky-dory?
>
> Because I just tried that, and it's still not.
>
> --
> Problem reports: http://cygwin.com/problems.html
> FAQ: http://cygwin.com/faq/
> Documentation: http://cygwin.com/docs.html
> Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
>
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple