GNU bug report logs - #8938
make timeout and CTRL-C

Previous Next

Package: coreutils;

Reported by: shay shimony <shayshim <at> gmail.com>

Date: Sun, 26 Jun 2011 21:48:01 UTC

Severity: normal

Fixed in version 8.13

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 8938 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: shay shimony <shayshim <at> gmail.com>
Cc: 8938 <at> debbugs.gnu.org
Subject: Re: bug#8938: make timeout and CTRL-C
Date: Mon, 27 Jun 2011 13:03:00 +0100
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
> CTRL-C.
> 
> Notes:
> CTRL-Z works.
> When executing timeout without make CTRL-C works.
> When executing make without timeout CTRL-C works.

Drats,

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.

cheers,
Pádraig.




This bug report was last modified 14 years and 25 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.