On Mon, 28 Jun 2004, Paul Jarc wrote: >>> How would you limit wall-clock time? Schedule SIGALRM with >>> setitimer and then exec the given command? >> >> I've long used a command of my own called 'alarm' that just does that. >> However, this strategy doesn't always work well if the command has >> subprocesses, since the signal is sent only to the exec'ed process. > >It also fails if the command uses setitimer itself. That could be >handled by forking and having the parent send SIGTERM to the child >when it gets its own SIGALRM. To handle the child processes, a new >process group could be created, but that might interfere with other >things.
Yes, keep the parent hanging around to handle the killing, particularly because you might want a two-stage kill (SIGTERM, sleep(5), SIGKILL). Process group helps when there might be sub-sub-processes, but as you say that has the potential to interfere with things which don't expect it, so perhaps make it a command-line parameter. So far then, I've got as potential command line args: - Seconds to sleep until first signal - Which signal to deliver at timeout #1 - Seconds to sleep until second signal (KILL) - Optionally create process group and kill all children - Exit status for the timeout condition The most common use I've got right now (and this is what prompted me to suggest it in the first place) is: $ timeout 10 ssh otherhost 'some random command' Cheers, Phil _______________________________________________ Bug-coreutils mailing list [EMAIL PROTECTED] http://lists.gnu.org/mailman/listinfo/bug-coreutils
