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

Tomas Kalibera tomas.kalibera at gmail.com
Mon Mar 19 20:20:40 CET 2018


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



More information about the R-devel mailing list