[Top][All Lists]

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

Re: how to get make to terminate itself at the first error?

From: Paul Smith
Subject: Re: how to get make to terminate itself at the first error?
Date: Wed, 04 Feb 2009 02:03:53 -0500

The reason SIGTERM behaves differently than SIGINT (for example) is
obvious: if you look at the fatal_error_signal() code you'll see that if
the signal is SIGTERM extra operations are run: in particular, it goes
through each of the child processes and sends a SIGTERM to each PID.
For SIGINT, no such loop is performed.

The difference you're seeing in behavior is because of make's fast path
vs. slow path.

If make determines that the command to be invoked is "simple enough",
make will simply fork/exec that command directly.  If the command is not
"simple enough", then make will fork a shell (/bin/sh) and pass the
command to the shell to run.  This has a big performance benefit.  The
"simple enough" determination is made by looking for various special
characters in the command string.

In the version that works as you want, the command "sleep 30" is simple
enough, so make just forks/execs the /usr/bin/sleep command directly
with an argument of 30.  When make sends that process a SIGTERM, it dies
(which is what you expect).

In the version that behaves differently the command to be run is
complex, containing shell operators like "&&" and "||", so make must run
a shell.  In this situation, the shell is the child PID that receives
the SIGTERM.  Apparently in this case the shell dies but doesn't kill
any of its children.

It may be more correct for make to send the SIGTERM to the child's
process group, rather than just to the PID itself.  However, I think
that this could cause problems because all of the sub-processes are
actually in the same process group (normally).  It's something that
would need to be considered carefully, for sure.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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