diff options
author | anton <anton@cvs.openbsd.org> | 2017-11-21 19:22:46 +0000 |
---|---|---|
committer | anton <anton@cvs.openbsd.org> | 2017-11-21 19:22:46 +0000 |
commit | 4795b283cd81a670171446239e3eda31fd911e0e (patch) | |
tree | aae3fc55fed49c46cb227c7ec9ab65fb3bb06e6e /regress | |
parent | c5013a6c6a3b6a83161ef790ecbcd4ddc0d05230 (diff) |
Do not exit 0 if the program was terminated due to receipt of a signal other
than SIGHUP.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/bin/ksh/edit/edit.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/regress/bin/ksh/edit/edit.c b/regress/bin/ksh/edit/edit.c index 62e73a2374a..17bae5c266f 100644 --- a/regress/bin/ksh/edit/edit.c +++ b/regress/bin/ksh/edit/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.6 2017/07/22 13:50:54 anton Exp $ */ +/* $OpenBSD: edit.c,v 1.7 2017/11/21 19:22:45 anton Exp $ */ /* * Copyright (c) 2017 Anton Lindqvist <anton@openbsd.org> * @@ -15,6 +15,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include <sys/wait.h> + #include <err.h> #include <errno.h> #include <poll.h> @@ -46,7 +48,7 @@ main(int argc, char *argv[]) pid_t pid; ssize_t n; size_t nin, nprompt, nread, nwrite; - int c, nready, ptyfd, readprompt, ret, timeout; + int c, nready, ptyfd, readprompt, ret, status, timeout; while ((c = getopt(argc, argv, "p:")) != -1) { switch (c) { @@ -142,6 +144,13 @@ main(int argc, char *argv[]) } } close(ptyfd); + while (waitpid(pid, &status, 0) == -1) + if (errno != EINTR) + err(1, "waitpid"); + if (WIFSIGNALED(status) && WTERMSIG(status) != SIGHUP) { + warnx("%s: terminated by signal %d", *argv, WTERMSIG(status)); + ret = 128 + WTERMSIG(status); + } printf("%.*s", (int)nread, out); |