I'm writing a "glue logic" library (.dll) that connects an external, proprietary application to our program (.exe). When the application requests (calling the right library function) our program should be started, and then the library continues operation, receiving data from the program over sockets, transforming produced data to the format digestible by the application, and returning it when the application performs calls to 'data getter' functions of the library.
I can start the program.exe relatively easily: fork a new process in the dll and call system()
or exec()
from the new process. On unload/end/stop call, I can send a 'quit' command to the program over sockets, and it will end just fine.
The problem is if the proprietary app, or the library crashes, is killed, or ends in an unexpected manner. I want program.exe to end, or be killed as well. While leaving it running wouldn't be that much of a problem, if the application is restarted, I'd need to search for old instances of the program, and kill them 'manually' before starting it anew (potentially with new startup parameters.)
I'd much prefer the program to die the moment the app or the library dies/crashes/is killed. I heard there is a special way of starting applications so they behave that way, but the person, who told me this can't recall how exactly it was done. Could you tell me?