0

I am writing a wrapper program in C++ for Linux, which calls several other binaries in sequence by use of the system() function.

While testing, I noticed that if I enter Ctrl + C in the terminal during execution of one of the child processes invoked by system(), only that child process gets halted. In other words, that subprocess stops, but the wrapper program is unaffected, and continues the subsequent binary calls.

This results in me having to continue inputting Ctrl + C on all children until the C++ binary runs to completion. I would like to allow my user to halt the entire wrapper program with Ctrl + C.

After researching other similar questions, it seems clear that one must leverage process groups on Linux to properly distribute the halt signal. However, I am unsure of how to relay a stop signal from a child process called by system() to the parent wrapper.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
gladshire
  • 81
  • 7
  • ```kill``` is a command in linux that kills a process with "PID" provided. So I'm assuming you could just call ```system("kill PID")``` with PID being the parent process ID and it will terminate it silently without anything displayed. But for all this you're gonna need to keep track of child process and find out if it got stopped (maybe look into log files for that ```/var/log```) and if it was then kill the parent process too – PIRIQITI Jan 12 '23 at 23:46

0 Answers0