www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - kill and thisProcessID

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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?
Jun 24 2015
next sibling parent "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> writes:
On Wednesday, 24 June 2015 at 11:39:51 UTC, Nordlöw wrote:
 What to do?
See also: Discussion at http://dlang.org/library/std/process/kill.html
Jun 24 2015
prev sibling next sibling parent reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Wednesday, 24 June 2015 at 11:39:51 UTC, Nordlöw wrote:
 What to do?
I believe the best solution is to add a new function Pid thisProcessPid() to std.process and refer to this from kill(Pid). Should I do PR?
Jun 24 2015
parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Wednesday, 24 June 2015 at 11:58:37 UTC, Nordlöw wrote:
 I believe the best solution is to add a new function

     Pid thisProcessPid()

 to std.process and refer to this from kill(Pid). Should I do PR?
PR at https://github.com/D-Programming-Language/phobos/pull/3448
Jun 28 2015
prev sibling next sibling parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 6/24/15 7:39 AM, "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?
Why not use core.sys.posix.signal: kill instead? You're already importing the module anyway. -Steve
Jun 24 2015
prev sibling parent "nkpm" <nkpm klsjdf.ezrt> writes:
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...
Jun 24 2015