X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=miscutils%2Ftimeout.c;h=9d56593bae4e456964b66266a96039a0e43cbc57;hb=2a870d091e86687c8b7b9e14b9c75815d40d7053;hp=f6e655accc22b28635159442ba8efd4244f90f11;hpb=21e8e8da6483c80a6054b06e48341968a7dccdd5;p=oweals%2Fbusybox.git diff --git a/miscutils/timeout.c b/miscutils/timeout.c index f6e655acc..9d56593ba 100644 --- a/miscutils/timeout.c +++ b/miscutils/timeout.c @@ -28,6 +28,12 @@ * rewrite 14-11-2008 vda */ +//usage:#define timeout_trivial_usage +//usage: "[-t SECS] [-s SIG] PROG ARGS" +//usage:#define timeout_full_usage "\n\n" +//usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n" +//usage: "Defaults: SECS: 10, SIG: TERM." + #include "libbb.h" int timeout_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; @@ -71,9 +77,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) sv1 = argv[optind]; sv2 = argv[optind + 1]; #endif - pid = vfork(); - if (pid < 0) - bb_perror_msg_and_die("vfork"); + pid = xvfork(); if (pid == 0) { /* Child: spawn grandchild and exit */ parent = getppid(); @@ -85,7 +89,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) bb_daemonize_or_rexec(0, argv); /* Here we are grandchild. Sleep, then kill grandparent */ grandchild: - /* Just sleep(NUGE_NUM); kill(parent) may kill wrong process! */ + /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */ while (1) { sleep(1); if (--timeout <= 0)