None of the overloads of kill are callable using argument types:

Ali Çehreli acehreli at yahoo.com
Tue May 19 01:18:53 UTC 2020


On 5/18/20 1:11 PM, BoQsc wrote:> I'm trying to kill my own process, but 
I'm being unsuccessful at the
 > compilation of the program. It seems that neither getpid nor
 > thisProcessID returns a correct type value for the kill function.

Of course, Adam D. Ruppe is right: You can simply return from main() in 
this case. Or, Pid is given to you for processes that you've spawned.

Your question brings one of my recent pet peeves in software: the 
'private' keyword.[1] In this case, it's Pid's constructor. I wanted to 
do the following but it failed because the constructor is private:

   auto p = new Pid(thisProcessID());

Ali

[1] I don't think 'private' keyword ever protected me. I'm pretty sure 
of it because if I've ever reached for undocumented features of a type 
or if I've ever used any member, say, having a name starting with '_', I 
would be sure to be punished in the future if the implementation 
changed. I know that and I'm sure it's very easy to teach it to 
beginners. It's too much protecting me from myself.

On the other hand, there have been multiple cases where 'private' 
keyword was hiding a useful feature: D runtime's GC statistics (at least 
in the past), some of std.getopt's parsing functions, etc. Note to self: 
Think twice before making anything 'private'.



More information about the Digitalmars-d-learn mailing list