[patch] wordexp resource cleanup (was: Re: wordexp bug)

Peter Rosin peda@lysator.liu.se
Tue Aug 21 18:39:00 GMT 2012

On 2012-08-17 22:03, Peter Rosin wrote:
> On 2012-08-17 21:49, Peter Rosin wrote:
>> On 2012-08-17 15:35, Yaakov (Cygwin/X) wrote:
>>> AFAICS wordexp(3) is completely broken, returning WRDE_SYNTAX no
>>> matter what I supply as the string.  STC attached.
>> I suspect you are using Cygwin, and if so I suspect that we have been
>> bitten by this change in bash-4.1-rc:
>> c.  The (undocumented) --wordexp option is no longer included by default.
>> The documentation states that you have to enable the WORDEXP_OPTION
>> when building bash, but I'll leave the details of how to do that to Eric,
>> the Cygwin bash maintainer.
> Maybe that was a bit too terse, the facts are that newlib forks
> "bash --wordexp" when wordexp(3) is called. Newer Cygwin bashes doesn't
> support the undocumented --wordexp option, presumably since bash no
> longer includes that option by default.  I found this out by looking
> up the documentation for the undocumented option in bash (i.e. the
> source).
> I should perhaps also mention, for new Cygwin recipients, that the
> original message appeared on the newlib list, which is why I could
> only suspect that Yaakov was using Cygwin, but that guess seemed
> kind of safe...

While looking up how wordexp worked I noticed that the resource handling
in the implementation was "somewhat lacking". So here's a follow-up to
take care of a few corner cases. (Not even compile-tested as I don't
know how to set that up without reading up on the subject, but you
wouldn't trust a newcomer anyway, right?)


	* libc/posix/wordexp.c (wordexp): Free all file descriptors
	and make sure the child is reaped in case of failure. Remove
	dead code while at it.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wordexp.patch
Type: text/x-patch
Size: 2127 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20120821/39fb4531/attachment.bin>

More information about the Newlib mailing list