summaryrefslogtreecommitdiffstats
path: root/term-utils
diff options
context:
space:
mode:
authorSami Kerola2012-11-06 22:14:14 +0100
committerKarel Zak2012-11-08 14:51:20 +0100
commit958e39d238fa8d880d1dda963c7f0fcd264c0f61 (patch)
tree8310c5bbcfa5daff6d48d07645bbfc443383d0c2 /term-utils
parentlibmount: convert /dev/root from mountinfo to the device name (diff)
downloadkernel-qcow2-util-linux-958e39d238fa8d880d1dda963c7f0fcd264c0f61.tar.gz
kernel-qcow2-util-linux-958e39d238fa8d880d1dda963c7f0fcd264c0f61.tar.xz
kernel-qcow2-util-linux-958e39d238fa8d880d1dda963c7f0fcd264c0f61.zip
script: do not try to close stderr twice
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>
Diffstat (limited to 'term-utils')
-rw-r--r--term-utils/script.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/term-utils/script.c b/term-utils/script.c
index ccd88738a..94a20da6c 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -159,7 +159,7 @@ main(int argc, char **argv) {
sigset_t block_mask, unblock_mask;
struct sigaction sa;
int ch;
- FILE *timingfd = stderr;
+ FILE *timingfd = NULL;
enum { FORCE_OPTION = CHAR_MAX + 1 };
@@ -274,9 +274,11 @@ main(int argc, char **argv) {
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;