kill and thisProcessID

nkpm via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jun 24 05:13:17 PDT 2015


On Wednesday, 24 June 2015 at 11:39:51 UTC, Nordlöw wrote:
> I have a process that shall suspend itself using SIGTSTP or 
> SIGSTOP.
>
> My current plan is
>
>     import std.process: thisProcessID, kill, Pid;
>     import core.sys.posix.signal: SIGKILL, SIGSTOP, SIGTSTP;
>     const thisPid = thisProcessID;
>     // some call to kill()
>
> but kill() needs a `Pid`
>
> so
>
>     kill(thisPid, SIGTSTP);
>
> fails and constructing Pid cannot be done because
>
>     kill(new Pid(thisPid), SIGTSTP);
>
> errors as
>
>     Error: class std.process.Pid member this is not accessible
>
> What to do?

in std.process, add a `kill()` overload that takes `thisPid` as 
argument, it will create the `Pid` as a local scoped instance and 
it will call the normal `kill()` version that takes a Pid as 
argument with the scoped `Pid` instance.
propose a PR for this overloaded `kill()` and wait dmd 2.068 
release.

Pid is well locked BTW: private constructor, final class...


More information about the Digitalmars-d-learn mailing list