[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8938: make timeout and CTRL-C

From: Pádraig Brady
Subject: bug#8938: make timeout and CTRL-C
Date: Mon, 27 Jun 2011 13:03:00 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20100227 Thunderbird/3.0.3

On 26/06/11 20:20, shay shimony wrote:
> Hello coreutils team,
> I found that if you run timeout inside make file then CTRL-C doesn't work.
> Really frustrating because I use timeout to terminate deadlocked tests, but
> can't stop them with CTRL-C as I used to.
> To reproduce copy the following into file named Makefile:
> all:
>         timeout 12 sleep 10
> Note there is a tab before "timeout 12 sleep 10".
> Then run at same directory where the file is located "make" and try to press
> Notes:
> CTRL-Z works.
> When executing timeout without make CTRL-C works.
> When executing make without timeout CTRL-C works.


That because SIGINT is sent by the terminal to the foreground group.
The issue is that `make` and `timeout` use much the same method
to control their jobs. I.E. they create their own process group
so they can terminate all sub-processes.

So in your case, make creates its own program group and is in the foreground.
Because timeout does too, it will not get SIGINT from the terminal.
Really `make` should propagate the SIGINT down, though I
suppose the same thing could be said for `timeout`.
I.E. the following demonstrates the same issue and times out after 10s
and is also unresponsive to CTRL-C:

  timeout 5 timeout 10 sleep 20

Note a handy way to see the process structure of timeout and make is:
ps -C make -C timeout -o ppid,pgid,pgrp,pid,tty,sess,comm

So what to do.
The cascaded timeouts could be handled by timeout sending a signal
to the child process as well as the process group.
But that won't fix the make case as `make` would have to do
something similar. Maybe I could add an option to not create
a separate group. I'll need to think a bit about this.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]