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

Felix Janda felix.janda at posteo.de
Thu Jul 30 20:33:55 MSK 2015


---
ToBeReplaced wrote:
> On openvt from kbd 2.0.2, `openvt -c 1 -fw /bin/false` exits with
> return code 0 instead of 1.

Can confirm on current git.

> There's a bug report from 2003 and a claim that it was resolved as of
> kbd 1.14.1: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=190386

The relevant commit is e37c78afc7fcee6d8edaa506b99d9081249adb7d. Maybe
it got broken since. Possibly it never worked at all.

> I'm not sure if this is a bug or desired behavior. 
> 
> How can I get the return code of the command passed to openvt?

Try this patch.
---
 src/openvt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/openvt.c b/src/openvt.c
index 1ba8912..1a36a69 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,7 @@ 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);
+		return WEXITSTATUS(retval);
 	}
 
 	return EXIT_SUCCESS;
-- 
2.3.6



More information about the kbd mailing list