From: Karel Zak <kzak@redhat.com>
To: Phillip Susi <psusi@ubuntu.com>
Cc: util-linux@vger.kernel.org
Subject: Re: script input redirection / eof handling
Date: Mon, 2 Dec 2013 13:54:21 +0100 [thread overview]
Message-ID: <20131202125421.GF5572@x2.net.home> (raw)
In-Reply-To: <20131202123659.GE5572@x2.net.home>
On Mon, Dec 02, 2013 at 01:36:59PM +0100, Karel Zak wrote:
> On Thu, Oct 31, 2013 at 10:21:10AM -0400, Phillip Susi wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > I came across an old bug filed in debian about script being redirected
> > from a file misbehaving.
>
> Do you mean something like:
>
> echo "ps uf" | script
>
> .. if yes, then it's pretty unexpected usage. The code expects that
> stdin is terminal. (For example it copy the current terminal
> attributes the new pseudo-terminal.)
>
> Unfortunately it does not check tcgetatt() return code so the problem
> is not visible. I'll fix it.
Note, that if you want to support this scenario (stdin is not a
terminal) then send a patch ;-)
I guess you have to initialize the terminal (see inlude/ttyutils.h,
reset_virtual_console()) and use this dummy struct termios instead of
the current 'tt'.
> Yep, I think it would be enough to add
>
> kill(0, SIGTERM);
>
> before done() in doinput() to avoid orphans.
This is probably not the best solution (because shell will print
"Terminated" etc.), but it's definitely better than orphans.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2013-12-02 12:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-31 14:21 script input redirection / eof handling Phillip Susi
2013-12-02 12:36 ` Karel Zak
2013-12-02 12:54 ` Karel Zak [this message]
2013-12-02 14:45 ` Phillip Susi
2013-12-02 17:02 ` Karel Zak
2013-12-02 18:06 ` Phillip Susi
2013-12-02 22:36 ` Karel Zak
2013-12-02 23:25 ` Karel Zak
2013-12-03 12:55 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20131202125421.GF5572@x2.net.home \
--to=kzak@redhat.com \
--cc=psusi@ubuntu.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox