[kbd] [PATCHv2] openvt -w: Return exit status from child

Felix Janda felix.janda at posteo.de
Sun Aug 9 11:46:02 MSK 2015


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



More information about the kbd mailing list