Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Process Execution

Moderators: kris

Posted: 09/27/08 05:15:50

http://dsource.org/projects/tango/wiki/PhobosTangoMigration claims that tango.sys.Process is a good alternative for std.process but afaik there is no cross platform sollution to execute a process without having to wait on it like there is in this sample piece of phobos code:

import std.process;


int main(char[][] args)
{
	execv(args[1],args[2..3]);
	return 0;
}

Author Message

Posted: 09/30/08 03:09:59

Would #718 solve this problem?

Posted: 09/30/08 08:12:08

Did you do the post about the detached process? Thats kind of where I would like it to go. If it was up to me I would have an optionall flag to either create the process attached, detached, or swicth current execution of the running process to the new one with detached as the default. There should be a static reference for the current running process aswell. I also read somewhere that with the current process execute on windows creates handles that doesnt get deleted if you don't call wait. For a language where everything is controlled by a gc it should be able to clean up windows handles in the d'tor.

Posted: 09/30/08 14:31:26

D-Crypt wrote:

Did you do the post about the detached process? Thats kind of where I would like it to go. If it was up to me I would have an optionall flag to either create the process attached, detached, or swicth current execution of the running process to the new one with detached as the default.

The planned enhancement is to select which standard handles to redirect. Redirecting all would be equivalent to your 'attached' and is the default today. Redirecting none would be 'detached', which could probably be a convenient enum value. Switch execution to a new image is not something I had planned. It could be an interesting addition.

D-Crypt wrote:

There should be a static reference for the current running process aswell.

Not sure what you mean by that. You mean a static Process instance? As Process is really meant to be something that controls the process, and not for getting information on a running process, I don't think that makes much sense. Perhaps the informational pieces can be split out into a separate class that contains info on a given process, and you could have a static instance of that.

D-Crypt wrote:

I also read somewhere that with the current process execute on windows creates handles that doesnt get deleted if you don't call wait. For a language where everything is controlled by a gc it should be able to clean up windows handles in the d'tor.

When a parent process is still running after a child dies, the OS must keep all the info about the child process around in case the parent still wants to access it. Once the parent process dies, then the resources will be cleaned up by the OS. Cleaning up the child process is not a generic function, and shouldn't be done by a destructor. It requires a call to wait, which could hang the death of the parent if done in destructors.