]> git.ipfire.org Git - thirdparty/util-linux.git/commit
script: script input redirection / eof handling
authorKarel Zak <kzak@redhat.com>
Tue, 3 Dec 2013 12:32:55 +0000 (13:32 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 3 Dec 2013 12:32:55 +0000 (13:32 +0100)
commit3822032da3b8431afb9ee2c0a66c210dd2223f8c
tree20075510ed40aee604b68f94ad2125eb241a26d9
parent1f77e9c3ad0b41640a82f2aca6eff18c98483610
script: script input redirection / eof handling

  echo "ps uf" | script

does not work because script assume that stdin is terminal and
it does not forward EOF to the pty.

This patch:

  * make non-tty use-case more robust (don't call tty ioclts to
    non-tty file descriptors.

  * send EOF (CTL('D') control char) to the master channel when
    detected eof by read() on stdin

  * wait for empty master and slave file descriptors to be sure that
    we don't miss date for typescript. This is also necessary to be
    sure that slave channel (shell) is completely initialized otherwise
    EOF is ignored.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/script.c