Chapter 7

Process Control

ps

ps [-lceaf] [-G gidlist] [-U uidlist]
-c   scheduler info ... copatible with prioCtl command
-e   everybody other users processes
-a   all list all processes (including usually hidden ones)
-f   full   show extra information
-l   llong shows a different set of extra information
-G   Groupid list is comma separated list of groups to look for
-U   Userid list is a comma separatd list of groups to look for


/usr/ucb/ps 
is the BSD version of ps...  uses different options.
You can find it by changing your PATH variable, or by explicitly calling for it by path

alias ps="/usr/ucb/ps"
causes the shell to pretend that any 'ps' command was typed as '/usr/bin/ps'
(can be used for other commands)

prstat

prstat -[av] [-n num]  [-p pid] [-s key] [-G gidlist] [-U uidlist] [-S key]  [interval]

-a   summarize by user
-n   number of processes to display
-P   Process ids to look for
-G   Group ids to look for
-s   sort key 
cpu   CPU usage (default)
time   execution time
rss   resident size set (memory usage)
pri   priority
-S   Sort in reverse
interval   how many seconds between upates

stdprocess

GUI process display and control program...

Signals

signals are normaly sent with the 'kill' command.
signals are often sent by the OS as a result of certain actions:

Processes can catch signals and respond to them in non-default ways  or ignore it.
The internal names of signals all start with SIG (eg: SIGINT), but most commands use the names without SIG prefix ( kill -INT 1234)

Notable signals:

1 HUP hangup (also parent process death)(
2 INT Interrupt (^c)
3 QUIT quit key (^\) -> can also cause core dumps

ILL,ABRT,FPE,BUS,SEGV,SYS various illegal instructions or memory access problems... will cause core dumps
9
KILL CANNOT BE STOPPED.   emergency only All files are immediately closed, and the process dies
23
STOP
stops the process (pauses it)
25
CONT
continue the process (after SIGSTOP)

psig

psig process_ids
lists the actions a process will take if it receives various signals

kill

sends a signal to (usually kills) a process


kill -L
    list all available signals and their numbrs

kill [-[s ]signal] pids
signal   can be a number, or a name (from kill -L or the list above)

nice

run a program that is nice (low priority)

nice [-increment |  -n increment ]  command

runs commad  with a niceness level of  increment (increment an be negative, which means it will be a CPU HOG)

renice

renice [-n increment] [-g gidlist] [-p pidlist] [-u uidlist

eg:
  renice -n 8 -p 415
makes process #415 run with a niceness of 8


pgrep /pkill

find/kill processes by name, uid,gid

pgrep [-lvx] [-G grouplist] [-U uidlist]  string

-l   long listing (includes pid and process name)
-v   vice versa  (print NON matching processes)
-x   exact match  string specifies full command name (otherwise substrings are OK)


pkill [-signal] [options]  string

options are the same as for pgrep , except for -l