Thread (6 messages) flat view 6 messages, 2 authors, 2016-08-11

Re: Easy shell question: how to make a script killing all his childs when killed?

From: Alex Riesen <hidden>
Date: 2016-08-11 20:40:04

Marco Costalba, Sat, Dec 09, 2006 16:16:32 +0100:
So how can I write the script to be sure that when stopped, it will
kill all his childern?
Strictly speaking: you can't. Anything you'd try will either be not
portable or involve quiet complex dependencies (like perl).
Are you sure you can't control each process independently?

Speaking not so strictly, you can use a script engine which supports
either signal handling or exit notification (i.e. sh has traps and
perl has %SIG and END{}). It's unsafe, ugly and not quiet portable to
that other operating system, but it often works and is (ab)used.
P.S: I have no way to exec the script in fancy ways, I can just start
it and get is PID.
Which is "fancy" enough. What do you mean "start"? Starting a new
process usually and notably involves forking and execing (even if the
first thing to exec will be your shell).
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help