Skip Menu |

This queue is for tickets about the Forks-Super CPAN distribution.

Report information
The Basics
Id: 132107
Status: new
Priority: 0/
Queue: Forks-Super

People
Owner: Nobody in particular
Requestors: Jon.Freeman [...] eastspring.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Fixes to the "poor man's alarm" in Forks::Super 0.97
Date: Wed, 11 Mar 2020 03:00:30 +0000
To: "bug-forks-super [...] rt.cpan.org" <bug-forks-super [...] rt.cpan.org>
From: Jon Freeman <Jon.Freeman [...] eastspring.com>
Hi, I need to start using the "poor man's alarm" in Forks::Super. In order to get it to work on my platform (64-bit Strawberry Perl 5.30.1 on Windows 10), I found I needed to make the following three changes to poor_mans_alarm() in ...\Forks\Super\Job\OS.pm: 1. Replace the first two occurrences of "kill" with "Forks::Super::kill". 2. Change the first argument of the second call to kill, from -9 to 'KILL'. Otherwise the presence of the '-' in front of the -9 affects the behavior of Forks::Super::Impl::_kill(): $kill_proc_group is not undef, then _get_killable_jobs_in_process_groups() is called, which returns an empty list, and so on. 3. Add a call to Forks::Super::waitpid($pid, 0) immediately after the second call to kill. Below is the full text of my proposed version of poor_mans_alarm() for your consideration please. Regards, Jon sub poor_mans_alarm { my ($pid, $time) = @_; if ($pid < 0) { # don't want to run in a separate process to kill a thread. if (CORE::fork() == 0) { $0 = "PMA[2]($pid,$time)"; sleep(1), Forks::Super::kill(0,$pid) || exit for 1..$time; # CHANGED Forks::Super::kill('KILL', $pid); # CHANGED Forks::Super::waitpid($pid, 0); # ADDED exit; } } # program to monitor a pid: my ($z,$p,$t) = ("PMA($pid,$time)",$pid,$time); my $prog = "\$0='$z';sleep 1,kill(0,$p)||exit for 1..$t;kill -9,$p"; if (&IS_WIN32) { $prog .= ";system 'taskkill /f /pid $pid >nul'"; my $pma_pid = system 1, qq[$^X -e "$prog"]; if ($Forks::Super::Debug::DEBUG) { debug("set poor man's alarm for $pid/$time in process $pma_pid"); } return $pma_pid; } else { my $pm_pid = CORE::fork(); if (!defined $pm_pid) { carp 'FSJ::OS::poor_mans_alarm: fork to monitor process failed'; return; } if ($pm_pid == 0) { exec($^X, '-e', $prog); } return $pm_pid; } } --------------------------------------------------------------------- Disclaimer This email is governed by terms and conditions found on http://www.eastspring.com/email-terms-and-conditions which contain important disclaimers. ---------------------------------------------------------------------

Message body is not shown because it is too large.