On Tue, 07 Sep 2010 16:51:48 -0400, Nick Sabalausky <a...@a.a> wrote:

"Steven Schveighoffer" <schvei...@yahoo.com> wrote in message
news:op.vioibdr2eav...@localhost.localdomain...
On Tue, 07 Sep 2010 14:54:46 -0400, Nick Sabalausky <a...@a.a> wrote:

"Kagamin" <s...@here.lot> wrote in message
news:i660qi$nu...@digitalmars.com...
Nick Sabalausky Wrote:

Does anyone who's done this sort of thing in D before, on Win or Lin,
know
of anything else in particular to be aware of?

There's no fork on windows. If you want a multithreaded server, it's
usually implemented with threads on windows.

That was just an example. CreateProcess/spawn/system are fine for my
purposes. I'm just talking about creating a child process and
communicating
with it via pipes.

The upcoming std.process changes will make this easy.


Ah cool, looking forward to it. I was just about ready to launch into a
bunch of std.process improvements myself ;) In the meantime, it seems that File has an undocumented constructor that takes a file handle instead of a
filename, so that should work for me.

Beware, it takes a file *descriptor*, which is different from a *HANDLE* on windows. In writing the updated std.process I had to write D code that mimics the internals of DMC's runtime in order to translate between file descriptors and handles, not a pretty sight...

The updates are being held back right now by bug 3979.

BTW, do any of the upcoming std.process changes do anything to help work
around Windows's exec being broken? By that I mean, exec is supposed to
*reuse* the current process when launching the new one, but on Windows (and I *don't* believe this is D-specific) it creates a *new* process and kills the old one, which fucks up anything that waits on the original process to
finish (such as the command-line). spawn(OVERLAY) has the same problem.

Windows' exec is a hack. std.process will not use it, instead, we'll use CreateProcess directly.

FWIW, we are not going to support fork or exec individually in std.process. We will only support creating a new process via fork+exec or CreateProcess. This is the common functionality among OSes.

If you want fork or exec individually, you have to use them on posix systems only, and call them directly.

-Steve

Reply via email to