Jazza1
Jazza1

Reputation: 41

CreateProcess: error creating process handle

Recently I've been developing an application in C# and I am using Mono to run it on Linux, I'm specifically testing on Debian 6.

After 2-8 hours the application keeps showing a warning, which is CreateProcess: error creating process handle. This warning has been posted on several mono mailing lists before, including mono-devel and mono-bugs, one specific post in the mono-devel list is http://mono.1490590.n4.nabble.com/Mono-CreateProcess-error-td1525870.html and in several other places the warning is talked about.

My application creates at least 10 processes per minute which run for under a second/half a second normally and I also called process.WaitForExit() and process.Dispose() to try help circumvent the error as suggested in other emails and as I've seen on Google, but unfortunately it has not helped.

When the error occurs it causes any future processes not to be created.

I was wondering if anybody has any potential solutions, It happens on both 2.10.2 and 2.10.6.

I saw this test/example case here:

http://lists.ximian.com/pipermail/mono-bugs/2009-September/092261.html

I've pasted it here for easy use:

System.Diagnostics.Process[] processes = new System.Diagnostics.Process[4096];
for (int i = 0; i < 4096; i++)
{
    Console.WriteLine("Starting: " + i.ToString());
    processes[i] = new System.Diagnostics.Process();
    processes[i].StartInfo.FileName ="echo";
    processes[i].StartInfo.Arguments = "\"hello mono \";";
    processes[i].Start();

    System.GC.Collect();
    System.GC.WaitForPendingFinalizers();
    System.Threading.Thread.Sleep(10);
}

Sorry for re-asking this question if it has been asked but I have not found a working solution yet.

Thanks!

Upvotes: 0

Views: 1199

Answers (1)

IanNorton
IanNorton

Reputation: 7282

I think you are using up file handles to talk to each process.

See here:

on 2009-09-06 08:59:10 UTC Joakim Sandström wrote:

Sorry for the double post.

This was resolved by creating a second loop, looping for HasExited. And then forcibly (try catch) running .Close on processes that had exited.

Does this work for you? I believe calling Process.Close() will close open file handles.

Upvotes: 1

Related Questions