From tomas.kalibera at gmail.com  Mon Mar 19 20:20:40 2018
From: tomas.kalibera at gmail.com (Tomas Kalibera)
Date: Mon, 19 Mar 2018 20:20:40 +0100
Subject: [Rd] 
 BUG: tools::pskill() returns incorrect values or non-initated
 garbage values [PATCH]
In-Reply-To: <CAFDcVCSwdcMOMcUknbBPjLyhzAZ9mG4TT2m0Bh25rG9RkZyx8w@mail.gmail.com>
References: <CAFDcVCSwdcMOMcUknbBPjLyhzAZ9mG4TT2m0Bh25rG9RkZyx8w@mail.gmail.com>
Message-ID: <662014f4-65f6-2873-d6c3-9c303e333240@gmail.com>

Thanks for spotting this, fixed in R-devel (including the Windows version).
Tomas


On 03/18/2018 09:53 PM, Henrik Bengtsson wrote:
> For the record, I've just filed the following bug report with a patch
> to https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=17395:
>
> tools::pskill() returns either random garbage or incorrect values,
> because the internal ps_kill() (a) it does not initiate the returned
> logical, and (b) it assigns the logical returned the 0/-1 value of C's
> kill().
>
> # Example 1: returns garbage due to non-initiated allocation
>
>> as.integer(tools::pskill(0))
> [1] 44764824
>> as.integer(tools::pskill(0))
> [1] 41609736
>> as.integer(tools::pskill(0))
> [1] 45003984
>
>
> # Example 2: returns 0 in success and -1 on failure
>
>> p <- parallel::mcparallel({ Sys.sleep(3600); 42L })
>> res <- tools::pskill(pid = p$pid, signal = tools::SIGKILL)
>> as.integer(res)
> [1] 0
>
>> p <- parallel::mcparallel({ Sys.sleep(3600); 42L })
>> res <- tools::pskill(pid = p$pid, signal = -1) ## invalid signal
>> as.integer(res)
> [1] -1
>
> /Henrik
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] BUG: tools::pskill() returns incorrect values or non-initated garbage values [PATCH]
Tomas Kalibera