Ad
How Can I Terminate A Background Process With Ctrlz In C?
I'm writing a script in C and I execute it with the &
in order to run it on the background.
I need to terminate the program with ctrl-z (SIGTSTP)
There is a main loop that intentionally prevents the script from terminating. I need to terminate it with ctrl-z and ctrl-z will not respond while the process is running the background.
How can I send the signal(from terminal) to the background process and how can I manipulate it?
Ad
Answer
You have to handle the signal and terminate the program when you receive the signal SIGTSTP.
To understand what I'm talking about: C signal handling - Wikipedia
Any guide/manual about handling signals in C should help you.
P.S.: you can terminate the program in any moment with function exit()
from <stdlib.h>
.
Ad
source: stackoverflow.com
Related Questions
- → OctoberCMS Backend Loging Hash Error
- → "failed to open stream" error when executing "migrate:make"
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → Create plugin that makes objects from model in back-end
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → How to install console for plugin development in October CMS
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → October CMS - Conditionally Load a Different Page
Ad