From: Andreas Henriksson <andreas@xxxxxxxx>
Message-ID: <20141009130557.GA20938@xxxxxxxx>
To: 764547@xxxxxxxxxxxxxxx
Date: Thu, 9 Oct 2014 15:05:57 +0200
Subject: Re: Bug#764547: Fwd: script from 2.25.1 may be broken (hangs)
Thanks for the improved testcase.
Spent 2 seconds looking and the finish indeed looks like it should
not be using WNOHANG (atleast) when explicitly called. Eg. like
the attached patch.
Would be great if someone was willing to take charge of looking
over this and getting a fix merged upstream. Poke me once merged
and a backport should be a trivial matter.
Regards,
Andreas Henriksson
diff --git a/term-utils/script.c b/term-utils/script.c
index b9f8738..b12b7fd 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -80,6 +80,7 @@
#define DEFAULT_OUTPUT "typescript"
+void sig_finish(int);
void finish(int);
void done(void);
void fail(void);
@@ -258,7 +259,7 @@ main(int argc, char **argv) {
/* setup SIGCHLD handler */
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
- sa.sa_handler = finish;
+ sa.sa_handler = sig_finish;
sigaction(SIGCHLD, &sa, NULL);
/* init mask for SIGCHLD */
@@ -385,17 +386,18 @@ doinput(void) {
}
if (!die)
- finish(0); /* wait for childern */
+ finish(1); /* wait for children */
done();
}
void
-finish(int dummy __attribute__ ((__unused__))) {
+finish(int wait) {
int status;
pid_t pid;
int errsv = errno;
+ int options = wait ? 0 : WNOHANG;
- while ((pid = wait3(&status, WNOHANG, 0)) > 0)
+ while ((pid = wait3(&status, options, 0)) > 0)
if (pid == child) {
childstatus = status;
die = 1;
@@ -405,6 +407,11 @@ finish(int dummy __attribute__ ((__unused__))) {
}
void
+sig_finish(int dummy __attribute__ ((__unused__))) {
+ finish(0);
+}
+
+void
resize(int dummy __attribute__ ((__unused__))) {
resized = 1;
}