Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using a Windows XP system,

We developed a program (Foobar) that makes a call to CreateProcess and then exits resulting in an non-terminating orphan process (Orphan). The issue is that when we attempt to move, copy, delete, etc. Foobar or its folder, Windows displays a cannot-dostuff-because-folder/program-is-being-used-by-another-process message since Foobar seems to still be tied to Orphan.

Why is this the case? We make calls to Close_Handle to release the thread and process resources immediately following CreateProcess() in Foobar. What dependencies or resources (if any exist) are left over that are tying Foobar to Orphan?
Posted
Comments
Rick Shaub 14-Apr-11 12:43pm    
Is the orphaning of the process intentional? If not you should call TerminateProcess() to end the process.
Xibal 14-Apr-11 13:09pm    
This is intentional and we now use ShellExecute() to launch the separate process instead, which works.

I just needed an answer to that issue to please the higher-ups with an explanation why CreateProcess() does not work. In fact, the solution proposed by John Simmons might work. I'll have to check.

It's because your "orphaned" process is still open, and hasn't released the filesystem resources that you're trying to access. What you need to do is change the scope of the process object so that when your app closes, the process in question can also be terminated.
 
Share this answer
 
v2
We've discovered the solution. The orphan process is inheriting and holding onto resources from its grandparent process, which prevents the grandparent process from running again.

Our main application needs this grandparent process in order to function correctly so all it took was to set the fifth paramter of CreateProcess (bInheritHandles) to FALSE to keep child processes from inheriting the parent process's handles. Once we did that, the grandparent process was able to start and function correctly even with the orhpan process running.

Thanks for your help!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900