FAQ

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.
This is an endless source of bugs when it comes to process management
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.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 8 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJul 29, '14 at 1:44p
activeJul 30, '14 at 12:29p
posts8
users5
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase