Write a C program that doesn’t terminate when Ctrl+Z is pressed. It prints a message “Cannot be suspended using Ctrl+Z” and continues execution.
We can use Unix signal for this. When Ctrl+Z is pressed, SIGTSTP signal is generated.
SIGTSTP signal is sent to a process by its controlling terminal to request it to stop (terminal stop). We can catch this signal and run our own defined signal.
The standard C library function signal() can be used to set up a handler for any of the above signals.
Cannot execute Ctrl+Z
This article is contributed by Pramod Kumar. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Write a C program that does not terminate when Ctrl+C is pressed
- C program to print a string without any quote (singe or double) in the program
- C program to detect tokens in a C program
- Output of C Program | Set 29
- How does a C program executes?
- Program to compute Log n
- How to compile 32-bit program on 64-bit gcc in C and C++
- Reasons for a C++ program crash
- 8085 program to add two 8 bit numbers
- 8086 program to add two 8 bit BCD numbers
- C program for pipe in Linux
- Program to check if two strings are same or not
- 8085 program to add 2-BCD numbers
- 8085 program to add two 16 bit numbers
- OpenMP | Hello World program