On 29 July 2014 15:49, James Bardin wrote:
When you use ^C, the shell is what takes care of terminating the entire
group, and Chris Hines' answer cover the other parts of your question.
When you use ^C, the shell is what takes care of terminating the entire
group, and Chris Hines' answer cover the other parts of your question.
and a hard lesson to learn. People generally don't realise that their
code behaves "as they expect it to" because the process group was torn
down by CTRL-C, not by their code.
Then they run it outside of a terminal context (or are signalled by a
mechanism other than pressing CTRL-C) and are left with unexplained
orphan processes which keep using resources. I've seen this come up in
numerous contexts.
For anyone wanting to appreciate how this works in detail, it is the
kernel (!) which invokes the process group kill when pressing CTRL-C.
If you want to achieve the same effect you must also use process
groups and signal the group.
Here's the code path in the kernel when you press CTRL-C:
https://github.com/torvalds/linux/blob/ac9dc67b730f3a1d10c5abbf91ed773d1e277646/drivers/tty/n_tty.c#L1127
via
https://github.com/torvalds/linux/blob/ac9dc67b730f3a1d10c5abbf91ed773d1e277646/drivers/tty/n_tty.c#L1248
via
https://github.com/torvalds/linux/blob/ac9dc67b730f3a1d10c5abbf91ed773d1e277646/drivers/tty/n_tty.c#L1287
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.