[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: Martin d Anjou
Subject: Re: how to get make to terminate itself at the first error?
Date: Wed, 4 Feb 2009 09:40:03 -0500 (EST)
User-agent: Alpine 1.10 (LNX 962 2008-03-14)

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.

Ah, in this case, I can use a trap:

all: t1 t2
        trap 'kill $$(jobs -p)' EXIT; sleep 60 && echo done || echo failed
        sleep 2 && exit 1

And it works. It's annoying to do this, but it works.

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.

This is not familiar territory for me. Does make run in the same process group as its children?

If I wanted the same effect as hitting control-c on the command line, wouldn't it be the way to do it: kill the process group rather than just the PID itself?


reply via email to

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