Re: odd script(1) behavior - script bug, man bug, ?
Greg Troxel <[email protected]> Tue, 16 Dec 2025 12:05:44 -0500
| Newsgroups | gmane.os.netbsd.devel.userlevel |
|---|---|
| Message-ID | <[email protected]> |
Mouse <[email protected]> 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$