Attempt #2 to fix script(1) if the standard input is closed: If we
read EOF from STDIN_FILENO, write zero bytes into the pseudo-terminal; this is interpreted as an EOF by the program being scripted. I've tested this with two non-interactive scripts: # echo 5 | script foo sh -c 'read x; sleep $x; echo bar' # echo bar | xargs script foo echo and one interactive program: # script foo more /etc/passwd and everything seems to work properly... PR: bin/56166, bin/57414, ports/57415, ports/60534 Approved by: rwatson (mentor) MFC after: 2 weeks
This commit is contained in:
parent
a20e9655b9
commit
d6a68195af
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=125848
@ -178,8 +178,10 @@ main(int argc, char *argv[])
|
||||
break;
|
||||
if (n > 0 && FD_ISSET(STDIN_FILENO, &rfd)) {
|
||||
cc = read(STDIN_FILENO, ibuf, BUFSIZ);
|
||||
if (cc <= 0)
|
||||
if (cc < 0)
|
||||
break;
|
||||
if (cc == 0)
|
||||
(void)write(master, ibuf, 0);
|
||||
if (cc > 0) {
|
||||
(void)write(master, ibuf, cc);
|
||||
if (kflg && tcgetattr(master, &stt) >= 0 &&
|
||||
|
Loading…
Reference in New Issue
Block a user