Returns TRUE if a process with the given PID exists, FALSE if a process with the given PID does not exists, and NA if it is not possible to check PIDs on the current system.
Details
There is no single go-to function in for testing whether a PID exists or not. Instead, this function tries to identify a working one among multiple possible alternatives. A method is considered working if the PID of the current process is successfully identified as being existing such that pid_exists(Sys.getpid()) is TRUE. If no working approach is found, pid_exists() will always return NA
regardless of PID tested. On Unix, including macOS, alternatives tools::pskill(pid, signal = 0L)
and system2("ps", args = pid) are used. On MS Windows, various alternatives of system2("tasklist", ...) are used. Note, some MS Windows machines are configures to not allow using tasklist on other process IDs than the current one.