[Rd] BUG: tools::pskill() returns incorrect values or non-initated garbage values [PATCH]
Henrik Bengtsson
henrik.bengtsson at gmail.com
Sun Mar 18 21:53:20 CET 2018
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
More information about the R-devel
mailing list