blob: 687b06091d98250519e1ff88e2fc7248c265b68b (
plain)
1 # PSRE README
2
3 Psre is short for **Process Snapshot Regex**. Essentially it is a simple
4 interface to quickly find PIDs of processes based on a regex match on the
5 `cmdline` in `/proc`. The normal operation is to run `ps` with any number of
6 flags, piped to any number of stream processors to extract matching process
7 IDs.
8
9 With `psre`, the command can be for example, `psre 'reg.*ex'`, to list all
10 processes with `reg` followed anywhere by `ex`. If the user wants to print a
11 list of the commands with the processes, the `-c,--cmdline` option can be
12 passed and the cmdline value will be printed next to the pid following a tab
13 character for easier splitting.
14
15 **Note** that when using `-c,--cmdline`, the original cmdline files in `/proc`
16 null-byte delimit the arguments of a command, leaving it only partially
17 printable. `psre` replaces those null bytes with the ascii space char (`0x20`
18 or `32 dec`) so the full cmdline is printable.
19
20
21 ## Example Usage: Bulk killing stuck processes
22
23 Sometimes webkit spins up many sub processes which get stuck and only a `kill
24 -9` will shut them down. This can be very cumbersome to fix by hand as there
25 can be many stuck PIDs. To do this easily with `psre`, run the following:
26
27 ```
28 kill -9 $(psre webkit --noself)
29 ```
30
31 **Note** the `--noself` switch which causes `psre` to filter its own PID from
32 the list so it is not also killed or an error thrown when this command runs.
|