fork/waitpid and std.concurrency.spawn
FreeSlave via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 22 09:11:30 PDT 2014
On Tuesday, 22 July 2014 at 14:26:05 UTC, Puming wrote:
> I've only found spawnProcess/spawnShell and the like, which
> executes a new command, but not a function pointer, like fork()
> and std.concurrency.spawn does.
>
> What is the function that does what I describe?
>
> On Tuesday, 22 July 2014 at 10:43:58 UTC, FreeSlave wrote:
>> On Tuesday, 22 July 2014 at 07:58:50 UTC, Puming wrote:
>>> Is there a fork()/wait() API similar to std.concurrency
>>> spawn()?
>>>
>>> The best thing I've got so far is module
>>> core.sys.posix.unistd.fork(), but it seems to only work in
>>> posix. Is there a unified API for process level concurrency?
>>> ideally with actor and send message support too.
>>
>> You need std.process.
I'm not sure what you're trying to do. Posix fork does not just
spawn function, it spawns new process as copy of its parent and
continue execution from the point where fork returns.
Windows creates processes in some different way, and it seems
there is no function with same functionality as Posix fork in
WinAPI (by the way you can try to find some implementations on
the Internet / use Cygwin / try to use Microsoft Posix Subsystem).
I think the reason why phobos does not have functionality you
want is that standard library should be platform-agnostic. So
instead of emulating things which are not supported by some
platform, it just truncates them.
More information about the Digitalmars-d-learn
mailing list