* [PATCH] script: do not try to close stderr twice
@ 2012-11-06 21:14 Sami Kerola
2012-11-08 13:52 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2012-11-06 21:14 UTC (permalink / raw)
To: util-linux; +Cc: Daniel Narvaez, Sami Kerola
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>
---
term-utils/script.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/term-utils/script.c b/term-utils/script.c
index ccd8873..94a20da 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;
--
1.8.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] script: do not try to close stderr twice
2012-11-06 21:14 [PATCH] script: do not try to close stderr twice Sami Kerola
@ 2012-11-08 13:52 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2012-11-08 13:52 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux, Daniel Narvaez
On Tue, Nov 06, 2012 at 09:14:14PM +0000, Sami Kerola wrote:
> Reported-by: Daniel Narvaez <dwnarvaez@gmail.com>
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-08 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-06 21:14 [PATCH] script: do not try to close stderr twice Sami Kerola
2012-11-08 13:52 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).