pskill

0th

Percentile

Kill a Process

pskill sends a signal to a process, usually to terminate it.

Keywords
utilities
Usage
pskill(pid, signal = SIGTERM)

SIGHUP SIGINT SIGQUIT SIGKILL SIGTERM SIGSTOP SIGTSTP SIGCHLD SIGUSR1 SIGUSR2

Arguments
pid

positive integers: one or more process IDs as returned by Sys.getpid.

signal

integer, most often one of the symbolic constants.

Details

Signals are a C99 concept, but only a small number are required to be supported (of those listed, only SIGINT and SIGTERM). They are much more widely used on POSIX operating systems (which should define all of those listed here), which also support a kill system call to send a signal to a process, most often to terminate it. Function pskill provides a wrapper: it silently ignores invalid values of its arguments, including zero or negative pids.

In normal use on a Unix-alike, Ctrl-C sends SIGINT, Ctrl-\ sends SIGQUIT and Ctrl-Z sends SIGTSTP: that and SIGSTOP suspend a process which can be resumed by SIGCONT.

The signals are small integers, but the actual numeric values are not standardized (and most do differ between OSes). The SIG* objects contain the appropriate integer values for the current platform (or NA_INTEGER_ if the signal is not defined).

Only SIGINT and SIGKILL will be defined on Windows, and pskill will always use the Windows system call TerminateProcess.

Value

A logical vector of the same length as pid, TRUE (for success) or FALSE, invisibly.

See Also

Package parallel has several means to launch child processes which record the process IDs.

psnice

Aliases
  • pskill
  • SIGHUP
  • SIGINT
  • SIGQUIT
  • SIGKILL
  • SIGTERM
  • SIGSTOP
  • SIGTSTP
  • SIGCONT
  • SIGCHLD
  • SIGUSR1
  • SIGUSR2
Examples
library(tools) # NOT RUN { pskill(c(237, 245), SIGKILL) # }
Documentation reproduced from package tools, version 3.5.3, License: Part of R 3.5.3

Community examples

Looks like there are no examples yet.