This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Prevent wordexp from modyfying terminal parameters


On 07/22/2010 11:45 AM, Moulding, Dan - 0663 - MITLL wrote:
> I have found that calling wordexp can, as an unfortunate side effect, change
> the controlling terminal's parameters. I tracked the problem down to the way
> wordexp invokes Bash to perform word expansion: stdout and stderr are
> redirected to a pipe, but stdin is left alone. It seems that if Bash sees that
> stdin is connected to a terminal, then Bash will immediately reset the
> terminal's parameters (presumably to some state that Bash considers sane).
> 
> The below patch is my first stab at fixing the problem. This makes wordexp also
> redirect stdin to the pipe before invoking Bash. It thereby prevents Bash from
> seeing it is connected to a terminal and avoids the reset of the controlling
> terminal's parameters.

Rather than redirecting stdin, would it be sufficient to add "-c" to the
list of arguments passed to bash?  Also, it is a bit faster to just
close(STDIN_FILENO) (and start bash with closed stdin) than to dup2 an
output-only pipe over to stdin (either way, bash doesn't appear to be
reading from stdin during --wordexp).

You probably also want to file a bug report with bug-bash AT gnu DOT org
that --wordexp should never need to do a check for interactive mode,
since it is a special-purpose invocation mode not even documented in the
man page.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]