mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
Fix issue 10587 - std.process.kill should fail for a terminated pid
https://github.com/dlang/phobos/issues/10587
This commit is contained in:
parent
68da19aed8
commit
8c6fca9ccd
1 changed files with 5 additions and 1 deletions
|
@ -2815,6 +2815,10 @@ void kill(Pid pid, int codeOrSignal)
|
|||
else version (Posix)
|
||||
{
|
||||
import core.sys.posix.signal : kill;
|
||||
if (pid.osHandle == Pid.invalid)
|
||||
throw new ProcessException("Pid is invalid");
|
||||
if (pid.osHandle == Pid.terminated)
|
||||
throw new ProcessException("Pid is already terminated");
|
||||
if (kill(pid.osHandle, codeOrSignal) == -1)
|
||||
throw ProcessException.newFromErrno();
|
||||
}
|
||||
|
@ -2856,7 +2860,7 @@ void kill(Pid pid, int codeOrSignal)
|
|||
do { s = tryWait(pid); } while (!s.terminated);
|
||||
version (Windows) assert(s.status == 123);
|
||||
else version (Posix) assert(s.status == -SIGKILL);
|
||||
assertThrown!ProcessException(kill(pid));
|
||||
assertThrown!ProcessException(kill(pid)); // Already terminated
|
||||
}
|
||||
|
||||
@system unittest // wait() and kill() detached process
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue