Kill processes on unload, on Windows
Guess the callr package fails to really kill the process on Windows is due to the same reason. Minimal Repro:
callr::r(function() {
message("hi")
Sys.sleep(3)
message("hi2")
Sys.sleep(3)
message("hi3")
}, timeout = 1)
#> Error: callr timed out hi
#> hi2
#> hi3
sessionInfo()
#> R version 3.4.1 (2017-06-30)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 7 x64 (build 7601) Service Pack 1
#>
#> Matrix products: default
#>
#> locale:
#> [1] LC_COLLATE=Chinese (Simplified)_People's Republic of China.936
#> [2] LC_CTYPE=Chinese (Simplified)_People's Republic of China.936
#> [3] LC_MONETARY=Chinese (Simplified)_People's Republic of China.936
#> [4] LC_NUMERIC=C
#> [5] LC_TIME=Chinese (Simplified)_People's Republic of China.936
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] Rcpp_0.12.13 crayon_1.3.4 digest_0.6.13
#> [4] rprojroot_1.3-2 assertthat_0.2.0 R6_2.2.2
#> [7] backports_1.1.2 magrittr_1.5 evaluate_0.10.1
#> [10] debugme_1.1.0 stringi_1.1.6 rstudioapi_0.7.0-9000
#> [13] callr_1.0.0.9000 rmarkdown_1.8 tools_3.4.1
#> [16] stringr_1.2.0 yaml_2.1.16 compiler_3.4.1
#> [19] processx_3.0.1 htmltools_0.3.6 knitr_1.18
Confirmed. Interesting. This is actually tested, and it does kill some processes, but seems like it does not kill R:
> system.time(processx::run("src/tools/px.exe", c("sleep", "100"), timeout = 1))
Error in processx::run("src/tools/px.exe", c("sleep", "100"), timeout = 1) :
System command timeout
Timing stopped at: 0 0 1.05
> system.time(processx::run(file.path(R.home("bin"), "R"), c("-q", "-e", "Sys.sleep(3)"), timeout = 1))
Error in processx::run(file.path(R.home("bin"), "R"), c("-q", "-e", "Sys.sleep(3)"), :
System command timeout
Timing stopped at: 0.02 0 3.3
This is a bug, btw, and does not have much to do with this issue.
It does kill the R process with the same pid reported by the processx object.
It's very weird. Although I can see the R process has been killed in the task manager of Windows, it seems like it's still running in the background...
The CRAN version of processx works fine for this case since it's using tools::pskill(). Do you need me to open a new issue because it's not much to do with the current?
@shrektan opened a separate issue for this: #96
Thanks!