Skip to content

Commit 111f73b

Browse files
committed
[perl #121230] fix kill -SIG on win32
v5.17.1-137-gc2fd40c tidied up perl's kill() implementation, making -SIGNAME be handled correctly, It also eliminated the use of the killpg() system/library call, which these days is usually just a thin wrapper over kill(). By doing this, it assumed that the following are functionally equivalent: killpg(pgrp, sig) kill(-pgrp, sig). Unfortunately this broke Window's use of the (perl-level) kill negative_value, pid, ... since under Windows, the killpg()/kill() identity doesn't hold (win32_kill() uses negative ids for fake-PIds, not process groups). Fix this by restoring the use of killpg() where available.
1 parent 3d147ac commit 111f73b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doio.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,12 +1789,15 @@ nothing in the core.
17891789
if (!(SvNIOK(*mark) || looks_like_number(*mark)))
17901790
Perl_croak(aTHX_ "Can't kill a non-numeric process ID");
17911791
proc = SvIV_nomg(*mark);
1792-
if (killgp)
1793-
{
1794-
proc = -proc;
1795-
}
17961792
APPLY_TAINT_PROPER();
1797-
if (PerlProc_kill(proc, val))
1793+
#ifdef HAS_KILLPG
1794+
/* use killpg in preference, as the killpg() wrapper for Win32
1795+
* understands process groups, but the kill() wrapper doesn't */
1796+
if (killgp ? PerlProc_killpg(proc, val)
1797+
: PerlProc_kill(proc, val))
1798+
#else
1799+
if (PerlProc_kill(killgp ? -proc: proc, val))
1800+
#endif
17981801
tot--;
17991802
}
18001803
PERL_ASYNC_CHECK();

0 commit comments

Comments
 (0)