help-make
[Top][All Lists]
Advanced

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

Re: how does make respond to ctrl-c?


From: Paul Smith
Subject: Re: how does make respond to ctrl-c?
Date: Mon, 02 Feb 2009 12:21:24 -0500

On Mon, 2009-02-02 at 10:57 -0500, Martin d'Anjou wrote:
> Hi,
> 
> Given this makefile:
> 
> all:
>       sleep 30 && echo ok || echo not ok
> 
> 
> If I hit control-c before the sleep is done, how come "not ok" is not 
> printed to the screen?

Because the shell that is running these commands is sent a SIGINT, and
so it quits immediately.  It has no chance to run any echo commands.

If you want it to do so, you'll have to arrange to catch the SIGINT in
your shell script (with trap) and do something with it.  This kind of
handling is VERY tricky to do correctly in the shell.

> I just want to understand how make propagages ctrl-c to commands.

All make's subshells are run in the same process group, and all signals
such as generated by ^C at the terminal are always sent to all processes
in that same process group.  So, it's not make that propagates these
signals.  The POSIX environment does it.







reply via email to

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