| purge_java | R Documentation |
Kill all or selected running Java processes. This function is useful to
stop Photon instances when not being able to kill the
process objects. Be aware that you can also
kill Java processes other than the photon application using this function!
purge_java(pids = NULL, ask = TRUE)
pids |
PIDs to kill. The PIDs should be Java processes. If |
ask |
If |
A list of running Java tasks is retrieved using ps (on Linux and MacOS)
or tasklist (on Windows). Tasks are killed using pkill
(on Linux and MacOS) or Taskkill (on Windows).
An integer vector of the pkill / Taskkill status
codes or NULL if not running Java processes are found.
# NOTE: These examples should only be run interactively or when you are
# sure that no other java processes are running simultaneously!
## Not run:
purge_java() # does nothing if no java processes are running
# start a new photon instance
dir <- file.path(tempdir(), "photon")
photon <- new_photon(dir, country = "Monaco")
photon$start()
# kill photon using a sledgehammer
purge_java()
photon$start()
# kill photon using a scalpel
library(ps)
p <- ps_handle(photon$proc$get_pid())
pids <- sapply(ps_children(p), ps::ps_pid)
purge_java(pids)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.