I have cases where the subprocess (or multiple ones) remain running. So I want to kick off a thread in the subprocess and every once in a while, see if the parent process is still valid. I plan to exit(0) if the parent is no longer valid. To do so, I have tried to use DuplicateHandle. I duplicate the main process' handle, convert it to a string and add it to the subprocess command line. In the subprocess, I convert the string back to a hex value (and verified I get the same value) and then try to use the handle in the subprocess. It is always an invalid handle when I pass it to DuplicateHandle. Is the subprocess created such that it cannot inherit handles?
In case it matters, I am not running in the sandbox as I have been unable to link with the lib.