how to prevent Ctrl+Break/Ctrl+C from closing both programs if one was launched from another by system() or CreateProcess()?-Collection of common programming errors

Add this::

#include 

 ...

signal (SIGINT, SIG_IGN);

After the signal() call, the program ignores Ctrl-Break. On Linux, ignoring signals propagates to child processes through fork()/exec().

I would expect Windows to reset the default signal handling on exec() due to the way the O/S + runtime library work. So if you want the child to ignore Break, add the code above to it too.