https://issues.dlang.org/show_bug.cgi?id=17250

Jon Degenhardt <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--- Comment #1 from Jon Degenhardt <[email protected]> ---
The ProcessPipes struct provides a method, pid(), that returns the Pid of the
attached process. The pid() method asserts if the private member is null:

    @property Pid pid() @safe nothrow
    {
        assert(_pid !is null);
        return _pid;
    }

The problem is that there is no method available to determine if pid is null
prior to call the pid() method.

In idiomatic use this unlikely to be an issue, as entering a block requiring
access to the pid is typically conditioned on successful creation of the pid.
An example from the doc:

    auto pipes = pipeProcess("my_application", Redirect.stdout |
Redirect.stderr);
    scope(exit) wait(pipes.pid);
    ... more code ...

In the above, the scope exit block is only entered if pid is successfully
created. However, if process creation is deferred, the pid might never be
assigned. E.g.

    ProcessPipes pipes;
    scope(exit) wait(pipes.pid);
    ... code ...
    pipes = pipeProcess("my_application", Redirect.stdout | Redirect.stderr);
    ... code ...

The above will fail in the 'wait(pipes.pid)' call if the _pid member is null.
What seems desired is a way to write something equivalent to:

    scope(exit) if (!pipes.isNullPid) wait(pipes.pid)

--

Reply via email to