I'm trying to interact with a really shitty, completely opaque API that creates two subprocesses inside a POSIX-like environment (OS X / Linux) in C. Basically, it runs an external program and provides rudimentary support for passing messages back and forth. The process tree looks something like this:
+ My_program
\
+ an initiation shell script (csh -f -c external_program_startup_script)
\
- the external program instance
When I press the control-c button in the terminal when it is executed My_program, the control terminal sends SIGINT to all processes in its process group - all three of the above processes. I want SIGINT to get to the program instance, but if it also gets into the shell of the script, then this middle process ends and the connection is disconnected.
Inside, My_programI can set up a signal handler to ignore SIGINT. But I have absolutely no control over the two child processes (the API does not even disclose their PID), so existing solutions, such as changing their process group or binding processors, will not work. Is there a way to prevent the control terminal from sending SIGINT to all processes in the foreground process group?
(In the MATLAB libeng API in question , which allows an external C program to process commands in MATLAB. But it has absolutely no functions for sending interrupts outside of what the OS provides.)
source
share