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
t1:
        trap 'kill $$(jobs -p)' EXIT; sleep 60 && echo done || echo failed
t2:
        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?

Martin


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to