tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: odd script(1) behavior - script bug, man bug, ?
Mouse <mouse%Rodents-Montreal.ORG@localhost> writes:
>> Does script(1) (not specified by POSIX) require that stdin is a tty?
>
> In practice, I think so. I tried
Thanks for the data points.
I read the code some, and believe
- the ioctl failure is a clue that the author expected that stdin is a
tty, but is not relevant to the behavior (retval not checked)
- the main loop reads from stdin and when that hits EOF, the top-level
process exits
- the child processes continue until the shell/command is done
- normally this exit/continue/exit is very fast as the command is
a shell that exits on EOF
This example shows behavior that seems to match my theory. Note the
delayed time for the sleep in 'outfile'. The first command (183)
returned immediately, and then after 2s foo was printed.
183$ script -c 'sleep 2;echo foo' outfile </dev/null
Script started, output file is outfile
Script done, output file is outfile
184$ foo
184$ cat outfile
Script started on Tue Dec 16 12:03:29 2025
foo
Script done on Tue Dec 16 12:03:31 2025
185$
Home |
Main Index |
Thread Index |
Old Index