popen bug [patch]

Eric Blake ebb9@byu.net
Tue Aug 22 20:24:00 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Cygwin popen does not match Linux popen when stdout is closed.
...
> Oops - when stdout is closed, and the pipe is output on child, cygwin
> popen mistakenly lost the pipe in both processes.
>
>
> The real world case that found this:
> cygwin$ echo 'errprint(esyscmd(echo hi))dnl' | m4 >&-
> sh: line 0: echo: write error: Bad file descriptor
>
> linux$ echo 'errprint(esyscmd(echo hi))dnl' | m4 >&-
> hi

Fixed as follows, along with a fix to obey POSIX "The popen() function
shall ensure that any streams from previous popen() calls that remain open
in the parent process are closed in the new child process."

2006-08-22  Eric Blake  <ebb9@byu.net>

	* libc/posix/popen.c (popen): Don't close output end of pipe in
	child if stdout was closed on entry.
	[HAVE_FCNTL]: In parent, mark file as close-on-exec, per POSIX.

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE61fw84KuGfSFAYARArN1AJ0ePKBbffbvvJaJOyW2XlsXUBFixwCffAvM
xu28ESQ/Md1uD58Bh77N+V4=
=oy2k
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: newlib.patch3
URL: <http://cygwin.com/pipermail/cygwin/attachments/20060822/312da959/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list