Skip to content

Commit

Permalink
Merge pull request #210 from AbrJA/master
Browse files Browse the repository at this point in the history
Bug fix for killing child processes when background = TRUE
  • Loading branch information
dselivanov authored Apr 14, 2024
2 parents 04fd819 + a8bf1ef commit 71feba8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/BackendRserve.R
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ BackendRserve = R6::R6Class(
#' @title Creates ApplicationProcess object
#'
#' @description
#' Creates ApplicationProcess to hold PID of the runnung applicaiton.
#' Creates ApplicationProcess to hold PID of the running application.
#'
ApplicationProcess = R6::R6Class(
classname = "ApplicationProcess",
Expand All @@ -345,12 +345,12 @@ ApplicationProcess = R6::R6Class(
},
#' @description
#' Send signal to process.
#' @param signal Singal code.
#' @param signal Signal code.
kill = function(signal = 15L) {
# kill service
tools::pskill(self$pid, signal)
# kill childs
system(sprintf("pkill -%s -P %s", signal, self$pid), wait = FALSE)
# get childs
child_pids <- suppressWarnings(system(sprintf("pgrep -P %s", self$pid), intern = TRUE))
# kill all
tools::pskill(c(self$pid, child_pids), signal)
}
)
)

0 comments on commit 71feba8

Please sign in to comment.