[PATCH] opentvt wait addition
James Simmons
jsimmons at infradead.org
Thu Mar 27 15:14:29 UTC 2008
> > --- 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");
>
> Does not compile: getopt32() does not take argc, only argv.
Sorry. The patch is from busybox 1.6.1. Plus I missed enabling openvt in
the menu so I missed the problems.
> Also, you need "+w" - you must not eat -options in
> "COMMAND [ARGS...]" part. Try "openvt -w ls -l"
Done.
> >
> > 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]);
>
> Bug.
>
> Strace of "./busybox openvt -w 20 ls true":
>
> 25653 vfork() = 25659
> 25659 execve("/root/bin/true", ["true"], [/* 32 vars */]) = -1 ENOENT (No such file or directory) D
> ^^^^
Your right. I missed that one. I have always been using it with one
command. Fixed.
>
> > + flags = wait4pid(pid);
> > + } else {
> > argv += 2;
> > BB_EXECVP(argv[0], argv);
> > - _exit(1);
>
> Indentation damage
>
> > + flags = EXIT_SUCCESS;
> > + }
> > + _exit(flags);
> > }
Ug. No diff with w option for the next patch.
> > 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" \
>
> All other help texts are formatted differently.
I was using the one below as a example. What exactly is wrong so I can fix
it?
More information about the busybox
mailing list