This is the mail archive of the
mailing list for the libstdc++ project.
RE: Information on a commit related to libstdc++/9533
- From: Pétur Runólfsson <peturr02 at ru dot is>
- To: "Paolo Carlini" <pcarlini at unitus dot it>
- Cc: "Nathan Myers" <ncm-nospam at cantrip dot org>,<libstdc++ at gcc dot gnu dot org>
- Date: Mon, 3 Mar 2003 13:52:38 -0000
- Subject: RE: Information on a commit related to libstdc++/9533
> Hi and thanks for your analysis.
> >This calls rdbuf()->close(), which calls _M_really_overflow, which
> >calls fwrite which should fail because the read end of the pipe
> >should have been closed, but since underflow was called at the
> >read end, the read end is still open.
> But, why the testcase didn't fail before reverting the
> O_NONBLOCK hunk?
> The underflow call was there before and it's there now.
The O_NONBLOCK caused the underflow() in filebuf::open() in the
child process to return immediately, which then caused the child
process to close the pipe and exit before the sleep() in the
parent process returned. When the parent process actually tried
to write something in filebuf::close(), the read end was no
longer open so the write failed.
When the O_NONBLOCK is removed, the child process waits in
underflow until the parent process closes the write end of the
pipe, so the read end is still open at the time the parent
process writes to the pipe, so the write succeeds.