summaryrefslogtreecommitdiffstats
path: root/term-utils
diff options
context:
space:
mode:
authorAndreas Henriksson2014-10-14 12:07:21 +0200
committerKarel Zak2014-10-14 12:07:21 +0200
commit032228c9af6fbda5177c47c3d410386895957555 (patch)
tree14cc8a85ae7a4e9712aeb83bc79dc8a609d13ad4 /term-utils
parentblkdiscard: fix underflow when offset is greater than device size (diff)
downloadkernel-qcow2-util-linux-032228c9af6fbda5177c47c3d410386895957555.tar.gz
kernel-qcow2-util-linux-032228c9af6fbda5177c47c3d410386895957555.tar.xz
kernel-qcow2-util-linux-032228c9af6fbda5177c47c3d410386895957555.zip
script: may be hangs
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'term-utils')
-rw-r--r--term-utils/script.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/term-utils/script.c b/term-utils/script.c
index 7d3787e96..78d7a3049 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;
}