The commit
cdd2a8c360c70d16804ace7cc923a6c6bb7c9ca9 broke script(1)
return value.
$ script -e -c "echo"; echo $?
1
The reason, as Daniel it reported, was that the script will close stderr
twice, once as timing file and atexit() in function close_stdout(). This
commit fixes the problem.
Reported-by: Daniel Narvaez <dwnarvaez@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sigset_t block_mask, unblock_mask;
struct sigaction sa;
int ch;
- FILE *timingfd = stderr;
+ FILE *timingfd = NULL;
enum { FORCE_OPTION = CHAR_MAX + 1 };
warn(_("fork failed"));
fail();
}
- if (child)
+ if (child) {
+ if (!timingfd)
+ timingfd = fdopen(STDERR_FILENO, "w");
dooutput(timingfd);
- else
+ } else
doshell();
} else {
sa.sa_handler = resize;