Skip to main content

Timeline for C SIGINT signal in Linux

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Jun 15, 2019 at 15:01 vote accept Albion Shala
Jun 1, 2019 at 23:22 comment added user313992 @AlbionShala But the fact that a SIGINT will be sent to all the processes in the group is essential, because it makes clear the dangerous futility of setting up a SIGINT handler as a way of key-binding; if the program is run as part of a pipeline or through a wrapper, it will still be (indirectly) killed by the 1st ^C (it will get a SIGPIPE when trying to write to the pipe, or have its children summarily killed while it's still counting up to 3). And changing tty attributes is no better, unless it's a full screen app (like vi or emacs) which has the tty all to itself.
Jun 1, 2019 at 22:04 comment added Gilles 'SO- stop being evil' @mosvy Thanks, I hadn't done that in a while and I should have spent more than 5s re-reading the man page. Regarding process groups, see footnote 2.
Jun 1, 2019 at 22:03 history edited Gilles 'SO- stop being evil' CC BY-SA 4.0
correct instructions to disable ctrl+c (thanks mosvy)
Jun 1, 2019 at 21:53 comment added user313992 IGNBRK has nothing to do with Ctrl-C being translated to SIGINT. It's ISIG in c_lflag who is controlling that (also c_cc[VINTR] can be set to 0 to disable it, or to another char). stty -intr is not a valid command. A VINTR/Ctrl-C won't send a signal to the "foreground process", but to the foreground process group (job), ie. when running a|b|c and pressing ^C, a signal will be sent to the a, b and c processes.
Jun 1, 2019 at 21:17 comment added Albion Shala Actually yes i mentioned that i am using C in Linux but it was editted, anyhow thanks a lot, i really appreciate it
Jun 1, 2019 at 21:14 comment added Gilles 'SO- stop being evil' @AlbionShala You never said what programming language you're using. And anyway programming is off-topic here when it goes beyond simple scripting. But a web search with the name of your programming language and "signal handler" and "tutorial" should give you examples.
Jun 1, 2019 at 21:06 comment added Albion Shala Can you briefly give me an example for second way ?
Jun 1, 2019 at 19:28 history answered Gilles 'SO- stop being evil' CC BY-SA 4.0