Timeline for C SIGINT signal in Linux
Current License: CC BY-SA 4.0
11 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 1, 2019 at 20:16 | comment | added | Albion Shala | I tried this but actually the program stops at the very first C i press still like in default mode, i press CTRL +C and it stops | |
| Jun 1, 2019 at 20:11 | comment | added | user313992 |
@RasoolZiafaty just because it's a proof of concept it should be correct. Besides, doing it correctly will make it shorter and simpler, not the reverse. Notice that the use of signal() instead of sigaction() is also highly dubious: on some systems, signal(3) will set the handler as with SA_RESETHAND ie the handler will be disabled after the first ^C.
|
|
| Jun 1, 2019 at 20:05 | comment | added | Rasool Ziafaty | Thanks @mosvy but this is a proof of concept code not a real one. why you don't add an answer and explain us more about what you know. because i didn't get what you said in your last comment. | |
| Jun 1, 2019 at 19:56 | comment | added | user313992 |
@AbhikBose You can easily change the keybinding from Ctrl-C to Ctrl-A with stty intr '^A' (from C you do that with tcsetattr(), look up the termios(3) manpage).
|
|
| Jun 1, 2019 at 19:54 | comment | added | user313992 |
you do not use printf and exit in signal handlers, ever. just think what happens if a SIGINT is coming while the program is running another printf or flushing the stdio buffers, or within a handler registered with atexit(3).
|
|
| Jun 1, 2019 at 19:29 | comment | added | Rasool Ziafaty | Changing key binding in your code is not possible as far as i know. but like i said you can change signal key binding in stty and in your terminal emulator. | |
| Jun 1, 2019 at 19:22 | comment | added | Abhik Bose |
What happens if I want to terminate with CTRL + AAA instead of CTRL + CCC?
|
|
| Jun 1, 2019 at 19:14 | history | undeleted | Rasool Ziafaty | ||
| Jun 1, 2019 at 19:14 | history | edited | Rasool Ziafaty | CC BY-SA 4.0 |
added 576 characters in body
|
| Jun 1, 2019 at 18:47 | history | deleted | Rasool Ziafaty | via Vote | |
| Jun 1, 2019 at 18:34 | history | answered | Rasool Ziafaty | CC BY-SA 4.0 |