Dangling cef client processes

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Dangling cef client processes

Postby rdh » Mon Jul 06, 2020 2:01 pm

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.
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Dangling cef client processes

Postby ndesktop » Mon Jul 06, 2020 4:09 pm

Looks like you are correclty doing DuplicateHandle in both processes. Maybe you need to use DUPLICATE_SAME_ACCESS?
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am

Re: Dangling cef client processes

Postby rdh » Mon Jul 06, 2020 4:27 pm

Hi ndesktop,

That's what I think (using it properly). I have tried that flag on each process together and independently. Even tried passing in 0. Microsoft has suggested the problem is with CEF's calling CreateProcess(Ex) disallowing handle inheritance. But, I don't have that code so I don't know. I guess I can hook up another OS hook and trap the CreateProcess(Ex) call and see what is being passed to it.

For now, I resorted to passing the parent process ID on the command line and using it in an OpenProcess call to get a HANDLE I then use in a thread to monitor if the parent has terminated. Slightly dangerous but I'm finding that CEF is fraught with perils (cannot run with a sandbox due to multiple issues, random crashes during shutdown, Web programmers and security teams telling me all this is putting their security at risk ...).

MS also suggested I check process creation times too to help avoid duplication of handles by the OS since I cannot pass the HANDLE via the command line and use it.
rdh
Techie
 
Posts: 33
Joined: Wed Jun 10, 2020 3:18 pm

Re: Dangling cef client processes

Postby ndesktop » Mon Jul 06, 2020 4:59 pm

rdh wrote:Hi ndesktop,

That's what I think (using it properly). I have tried that flag on each process together and independently. Even tried passing in 0. Microsoft has suggested the problem is with CEF's calling CreateProcess(Ex) disallowing handle inheritance. But, I don't have that code so I don't know. I guess I can hook up another OS hook and trap the CreateProcess(Ex) call and see what is being passed to it.

For now, I resorted to passing the parent process ID on the command line and using it in an OpenProcess call to get a HANDLE I then use in a thread to monitor if the parent has terminated. Slightly dangerous but I'm finding that CEF is fraught with perils (cannot run with a sandbox due to multiple issues, random crashes during shutdown, Web programmers and security teams telling me all this is putting their security at risk ...).

MS also suggested I check process creation times too to help avoid duplication of handles by the OS since I cannot pass the HANDLE via the command line and use it.


OpenProcess with CreateToolhelpSnapshot32 is what I am using myself. I don't remember how CefExecuteProcess falls back into CreateProcess right now, but you might be right.
ndesktop
Master
 
Posts: 750
Joined: Thu Dec 03, 2015 10:10 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 28 guests