This patch allows openvt to wait for command completion.

diff -urwN busybox.orig/console-tools/openvt.c busybox/console-tools/openvt.c
--- busybox.orig/console-tools/openvt.c 2008-03-26 09:51:27.000000000 -0400
+++ busybox/console-tools/openvt.c      2008-03-26 10:10:50.000000000 -0400
@@ -16,12 +16,16 @@
 int openvt_main(int argc, char **argv)
 {
        char vtname[sizeof(VC_FORMAT) + 2];
+       pid_t pid;
+       int flags;
+
+       flags = getopt32(argc, argv, "w");
 
        if (argc < 3)
                bb_show_usage();
 
        /* check for illegal vt number: < 1 or > 63 */
-       sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
+       sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[optind], 1, 63));
 
        bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
        /* grab new one */
@@ -30,7 +34,13 @@
        xdup2(0, STDOUT_FILENO);
        xdup2(0, STDERR_FILENO);
 
+       if (flags & 1) {
+               pid = xspawn(&argv[argc-1]);
+               flags = wait4pid(pid);
+       } else {
        argv += 2;
        BB_EXECVP(argv[0], argv);
-       _exit(1);
+               flags = EXIT_SUCCESS;
+       }
+       _exit(flags);
 }
diff -urwN busybox.orig/include/usage.h busybox/include/usage.h
--- busybox.orig/include/usage.h        2008-03-26 09:52:06.000000000 -0400
+++ busybox/include/usage.h     2008-03-26 10:08:28.000000000 -0400
@@ -2816,9 +2816,11 @@
        "to standard output. With no FILE or when FILE is -, read standard 
input."
 
 #define openvt_trivial_usage \
-       "VTNUM COMMAND [ARGS...]"
+       "[-w] VTNUM COMMAND [ARGS...]"
 #define openvt_full_usage \
-       "Start a command on a new virtual terminal"
+       "Start a command on a new virtual terminal\n" \
+       "\nOptions:" \
+       "\n     -w      wait for command to complete" \
 #define openvt_example_usage \
        "openvt 2 /bin/ash\n"
 
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to