[kbd] [PATCHv2] openvt -w: Return exit status from child
Felix Janda <[email protected]> Sun, 9 Aug 2015 10:46:02 +0200
| Newsgroups | dev.linux.lists.kbd |
|---|---|
| Message-ID | <20150809084602.GA13418@nyan> |
Return 128+signum when child exited because of a signal.
---
src/openvt.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/openvt.c b/src/openvt.c
index 1ba8912..4386584 100644
--- a/src/openvt.c
+++ b/src/openvt.c
@@ -386,7 +386,6 @@ main(int argc, char *argv[])
if (do_wait) {
int retval = 0; /* actual value returned form process */
- wait(NULL);
waitpid(pid, &retval, 0);
if (show) { /* Switch back... */
@@ -403,7 +402,10 @@ main(int argc, char *argv[])
/* if all our stuff went right, we want to return the exit code of the command we ran
super vital for scripting loops etc */
- return(retval);
+ if (WIFEXITED(retval))
+ return WEXITSTATUS(retval);
+ else
+ return 128 + WTERMSIG(retval);
}
return EXIT_SUCCESS;
--
2.4.6