% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/low-level.R
\name{ps_kill}
\alias{ps_kill}
\title{Kill one or more processes}
\usage{
ps_kill(p = ps_handle(), grace = 200)
}
\arguments{
\item{p}{Process handle, or a list of process handles.}

\item{grace}{Grace period, in milliseconds, used on Unix. If it is not
zero, then \code{ps_kill()} first sends a \code{SIGTERM} signal to all processes
in \code{p}. If some proccesses do not terminate within \code{grace}
milliseconds after the \code{SIGTERM} signal, \code{ps_kill()} kills them by
sending \code{SIGKILL} signals.}
}
\value{
Character vector, with one element for each process handle in
\code{p}. If the process was already dead before \code{ps_kill()} tried to kill
it, the corresponding return value is \code{"dead"}. If \code{ps_kill()} just
killed it, it is \code{"killed"}.
}
\description{
Kill the process with SIGKILL preemptively checking whether PID has
been reused. On Windows it uses \code{TerminateProcess()}.
}
\details{
Note that since ps version 1.8, \code{ps_kill()} does not error if the
\code{p} process (or some processes if \code{p} is a list) are already terminated.
}
\examples{
\dontshow{if (ps::ps_is_supported() && ps::ps_os_type()["POSIX"] && ! ps:::is_cran_check()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
px <- processx::process$new("sleep", "10")
p <- ps_handle(px$get_pid())
p
ps_kill(p)
p
ps_is_running(p)
px$get_exit_status()
\dontshow{\}) # examplesIf}
}
\seealso{
Other process handle functions: 
\code{\link{ps_children}()},
\code{\link{ps_cmdline}()},
\code{\link{ps_connections}()},
\code{\link{ps_cpu_times}()},
\code{\link{ps_create_time}()},
\code{\link{ps_cwd}()},
\code{\link{ps_descent}()},
\code{\link{ps_environ}()},
\code{\link{ps_exe}()},
\code{\link{ps_handle}()},
\code{\link{ps_interrupt}()},
\code{\link{ps_is_running}()},
\code{\link{ps_memory_info}()},
\code{\link{ps_name}()},
\code{\link{ps_num_fds}()},
\code{\link{ps_num_threads}()},
\code{\link{ps_open_files}()},
\code{\link{ps_pid}()},
\code{\link{ps_ppid}()},
\code{\link{ps_resume}()},
\code{\link{ps_send_signal}()},
\code{\link{ps_shared_libs}()},
\code{\link{ps_status}()},
\code{\link{ps_suspend}()},
\code{\link{ps_terminal}()},
\code{\link{ps_terminate}()},
\code{\link{ps_uids}()},
\code{\link{ps_username}()}
}
\concept{process handle functions}
