[PATCH] Prevent wordexp from modyfying terminal parameters

Moulding, Daniel - 0663 - MITLL dmoulding@ll.mit.edu
Tue Aug 3 18:22:00 GMT 2010

> Dan, can you provide a sample test scenario?
> -- Jeff J.

I apologize for taking so long to get back to you with this. It turned out
to be not-so-trivial to demonstrate this with a simplified case. Today I
finally had some free time to take another crack at distilling this down to
a simpler case (see the attachment).

It turns out that there are some quirks involved here, that I must admit I
don't fully understand. First, the terminal parameters must be initially set
from a C++ object's global constructor (?). Second, this has to be done from
a DLL (???). I'm not sure what this means and I'm open to the possibility
that I'm doing something that I shouldn't be (such as calling tcsetattr from
a global constructor).

I couldn't successfully reproduce this with just C or without using a DLL.
In my specific case, it would be possible for me to work around the issue by
not calling tcsetattr from the global constructor, but I'd like someone
else's opinion as to whether this simplified example should work.

In any case, redirecting (or closing) stdin before execing Bash in wordexp
resolves wordexp's unexpected "terminal attributes reset" side-effect.

-- Dan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: wordexp-test.tar.gz
Type: application/x-gzip
Size: 1563 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20100803/26b4aafb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5262 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20100803/26b4aafb/attachment-0001.bin>

More information about the Newlib mailing list