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

BoQsc vaidas.boqsc at gmail.com
Mon May 18 20:11:25 UTC 2020


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.

HelloWorld.d(24): Error: none of the overloads of kill are 
callable using argument types (int), candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\process.d(2327):       
  std.process.kill(Pid pid)
C:\D\dmd2\windows\bin\..\..\src\phobos\std\process.d(2338):       
  std.process.kill(Pid pid, int codeOrSignal)


HelloWorld.d


import std.stdio   : write, writeln, readln, writefln;
import std.process : executeShell, kill, thisProcessID;
import core.thread.osthread : getpid;

void main() {
	executeShell("title HelloWorld");
	executeShell("chcp 65001");
     writeln("Hello, World!");
	writeln("
	 ▄ .▄▄▄▄ .▄▄▌  ▄▄▌            ▄▄▌ ▐ ▄▌      ▄▄▄  ▄▄▌  ·▄▄▄▄
	██▪▐█▀▄.▀·██•  ██•  ▪         ██· █▌▐█▪     ▀▄ █·██•  ██▪ ██
	██▀▐█▐▀▀▪▄██▪  ██▪   ▄█▀▄     ██▪▐█▐▐▌ ▄█▀▄ ▐▀▀▄ ██▪  ▐█· ▐█▌
	██▌▐▀▐█▄▄▌▐█▌▐▌▐█▌▐▌▐█▌.▐▌    ▐█▌██▐█▌▐█▌.▐▌▐█•█▌▐█▌▐▌██. ██
	▀▀▀ · ▀▀▀ .▀▀▀ .▀▀▀  ▀█▄▀▪     ▀▀▀▀ ▀▪ ▀█▄▀▪.▀  ▀.▀▀▀ ▀▀▀▀▀•

");
	writefln("Current process id: %s", getpid());
	writeln("This process id: ", thisProcessID());
	
	string line;
	write("Your Input: ");
	while ((line = readln()) !is null) {
	        writeln(line);
			kill(thisProcessID());
			write("Your Input: ");

			}
}


More information about the Digitalmars-d-learn mailing list