Skip to content

One of the following:

  • "idle": Process being created by fork, or process has been sleeping for a long time. macOS only.

  • "running": Currently runnable on macOS and Windows. Actually running on Linux.

  • "sleeping" Sleeping on a wait or poll.

  • "disk_sleep" Uninterruptible sleep, waiting for an I/O operation (Linux only).

  • "stopped" Stopped, either by a job control signal or because it is being traced.

  • "uninterruptible" Process is in uninterruptible wait. macOS only.

  • "tracing_stop" Stopped for tracing (Linux only).

  • "zombie" Zombie. Finished, but parent has not read out the exit status yet.

  • "dead" Should never be seen (Linux).

  • "wake_kill" Received fatal signal (Linux only).

  • "waking" Paging (Linux only, not valid since the 2.6.xx kernel).

Usage

ps_status(p = ps_handle())

Arguments

p

Process handle.

Value

Character scalar.

Details

It might return NA_character_ on macOS.

Works for zombie processes.

Note on macOS

On macOS ps_status() often falls back to calling the external ps program, because macOS does not let R access the status of most other processes. Notably, it is usually able to access the status of other R processes.

The external ps program always runs as the root user, and it also has special entitlements, so it can typically access the status of most processes.

If this behavior is problematic for you, e.g. because calling an external program is too slow, set the ps.no_external_ps option to TRUE:

options(ps.no_external_ps = TRUE)

Note that setting this option to TRUE will cause ps_status() to return NA_character_ for most processes.

Examples

p <- ps_handle()
p
#> <ps::ps_handle> PID=6015, NAME=R, AT=2024-10-29 08:51:51.83
ps_status(p)
#> [1] "running"