Reagan: CreateProcess()?

Regan Heath regan at netmail.co.nz
Fri Jul 13 07:02:57 PDT 2007


okibi wrote:
> Hey Reagan,
> 
> I took your suggestion about getting system() to run without a window by creating a CreateProcess(). I looked at your example on:
> 
> http://www.digitalmars.com/d/archives/digitalmars/D/29556.html
> 
> I can't get it to compile! I'm getting an error for expecting type ulong on line 107 in your pipestream.d file.
> 
> Any ideas?

Change seek to:

		override ulong seek(long offset, SeekPos whence)
		{
			assertSeekable();
			return 0;
		}

The pipestream isn't seekable so it never returns.

After doing that you get a problem with:

		HANDLE write = INVALID_HANDLE_VALUE;
		HANDLE read = INVALID_HANDLE_VALUE;

just remove the "= INVALID.." it's not really necessary as the 
constructor always assigns values to these.

There are several string/char[] changes, eg.

1)

class ProcessException : Exception
{
	version(Windows) {
		this(string msg) { super(msg ~ ": " ~ sysErrorString(GetLastError())); }
	}
	version(linux) {	
		//for some reason getErrno does not link for me?
		this(string msg) { super(msg ~ ": " ~ 
std.string.toString(strerror(getErrno()))); }
	}
}

2)

	string readLine()
	{
		return pout.readLine();
	}
	
	string readError()
	{
		return perr.readLine();
	}

	void writeLine(string line)
	{
		pin.writeLine(line);
	}

After that I think it should compile, I can't guarantee this code works 
however ;)

Tango has a tango.sys.Pipe and tango.sys.Process which probably do very 
similar stuff.

Regan


More information about the Digitalmars-d-learn mailing list