[Pkg-kbd-devel] Bug#190386: Patch

Jim Paris jim at jtan.com
Wed May 23 09:04:37 UTC 2007


tags 190386 +patch
thanks

Hi,

Without -w, it is not possible to get the return value of the child,
because openvt returns without waiting for the child to finish.

With -w, the below patch allows openvt to match the child's return
status when the child successfully exits.  In case of signal or other
abnormal exit, it will return status 127, which is the same code it
uses when the exec() fails.

-jim


diff -urN kbd-1.12.orig/openvt/openvt.c kbd-1.12/openvt/openvt.c
--- kbd-1.12.orig/openvt/openvt.c	2004-01-03 11:05:17.000000000 -0500
+++ kbd-1.12/openvt/openvt.c	2007-05-23 05:00:07.000000000 -0400
@@ -51,6 +51,7 @@
    char verbose = FALSE;
    char direct_exec	= FALSE;
    char do_wait	= FALSE;
+   int status;
    char as_user = FALSE;
    char vtname[sizeof VTNAME + 2]; /* allow 999 possible VTs */
    char *cmd = NULL, *def_cmd = NULL, *username = NULL;
@@ -276,7 +277,7 @@
    }
 
    if ( do_wait ) {
-      wait(NULL);
+      wait(&status);
       if (show) { /* Switch back... */
 	 if (ioctl(consfd, VT_ACTIVATE, vtstat.v_active)) {
 	    perror("VT_ACTIVATE");
@@ -293,6 +294,10 @@
 	   return(8);
 	 }
       }
+      if (WIFEXITED(status))
+	      return WEXITSTATUS(status);
+      else
+	      return 127;
    }
 
    return 0;




More information about the Pkg-kbd-devel mailing list