tags:

views:

79

answers:

1

How do I invoke a child process from C# with UseShellExecute set to false and allow file deletion?

The child process is a java program creates a 0 byte file, transfers it to a remote server, and deletes it. This functionality works when I execute the java program from the Windows command line.

If I invoke the java program from C# using a System.Diagnostics.Process instance with StartInfo.UseShellExecute set to false, the child process does not delete the file. In fact, processing stalls and nothing happens. If the Process object's StartInfo.UseShellExecute property is set to true, the child process can delete the file, and execution of the parent process proceeds. However, I need the UseShellExecute property to be false so I can redirect output from the child process.

A: 

Does this sound like it might be the cause?

http://hackage.haskell.org/trac/ghc/ticket/2650

(or, more specifically, the Java issue linked from there)

I ran into a similar problem some time ago, and it turned out to be caused by unexpected handle inheritance, but I don't quite see how that would cause the problem you describe.

Tim Sylvester
After posting my question, I discovered that the java process is stalling before it gets to the file deletion! I don't know how to debug the child process so I'm inserting logging statements. The java process dies when it makes a synchronized call to get a java.util.Collection<T> reference.Thanks for your help.
ecruz3
Not sure what you're using for Java development, but in NetBeans you can use the Attach Debugger command in the Debug menu to debug a process that's already started.
Tim Sylvester