I have a program (lets call it prog1.exe) that launches another program (lets call it prog2.exe) with:
// in prog1.exe:
boost::process::spawn("prog2.exe", ...);
If I launch cmd.exe:
C:\>
and then run prog1.exe:
C:\> prog1.exe
then:
- prog1.exe starts running
- prog1.exe launches prog2.exe and prog2.exe starts running
- prog1.exe completes successfully.
- prog2.exe continues running.
If I then close cmd.exe while prog2.exe is still running, it will terminate prog2.exe before it has completed.
Why does that happen? Why does prog1.exe ending NOT terminate prog2.exe, while cmd.exe ending DOES terminate prog2.exe ?
Is there any way to make it so that closing cmd.exe will not terminate prog2.exe?