Welcome to the ``tip of the week'', a pithy kickshaw provided on a sometimes weekly basis. This is a brief discussion of process management using the Unix functions `ps' and `kill'. We stick to the basics below; for more information see the manual pages (type ``man ps'' in any shell window). Also, be warned that details on the ps function vary between different dialects of Unix. A ``process'' is a running program. For example, you have a shell process running any time that you are logged in to one of our computers, and if you are sitting at a workstation with the window system running then you have processes running to create and manage the window system, along with xterm and shell processes, plus any other applications you might have open such as clocks, calendars, and mail readers. The operating system takes care of the complicated job of sharing computer time among many competing processes. The issue of tracking and managing your own processes arises for a couple of reasons. You may have left a job running in background using the ampersand(`&') directive; a dropped modem connection might have left some garbage behind; or a running program might have become unresponsive. The `ps' command (think ``process status'') displays information about processes, potentially listing all the processes running on a CPU for any user. The information available can be daunting, so ps has a large number of flags to shape its report format. % ps Without any flags, the ps command lists processes running with your user ID and attached to a terminal. (For these purposes, different xterm windows count as distinct terminals.) % ps -x The `x' flag directs ps to exhibit all the processes running under your user ID, whether or not they are attached to a terminal. If you suspect that you have some leftover programs consuming resources then this flag is appropriate. Here is an example: % ps -x PID TT STAT TIME COMMAND 109 co IW 0:03 -tcsh (tcsh) 2263 co IW 0:00 /bin/sh /math/x/startx 2267 co IW 0:00 xinit /depot/X11R5/lib/X11/xinit/xinitrc.system 2268 co S 120:37 /depot/X11R5/bin/XsunMono :0 2269 co S 2:18 twm 2281 p0 IW 0:37 xwalld 2285 p1 S 0:19 -tcsh (tcsh) 9071 p1 R 0:00 ps -x This basic output format includes some status and location information along with each process's identification number (PID). Note that the `ps' process itself appeared in the list. Suppose you want to delete one of your processes, for example an old chess game or ftp session that never closed out properly. This chore should be done with the `kill' command, which sends signals of various kinds to processes, including signals which terminate most running processes. To kill a process, you need its process identification number from the PID column of a ps report. Many processes will shut down if you simply type ``kill PID'', as in % ps -x PID TT STAT TIME COMMAND 21529 p1 I 1:10 xbiff % kill 21529 -- if this does not work, then a nearly sure kill is possible with the `-9' or `-KILL' flag: % kill -KILL 21529 You can't kill processes owned by other users and it is usually impossible to kill processes which have become `zombies', as indicated by a ``Z'' in the status column of ps's output. The superuser can kill any of your processes, except zombies, so if you have trouble with a runaway program please notify consult@math.ufl.edu. Past Tips of the Week are found in /usr/local/tips. They may be consulted through the Documentation/Online Help menu item of the window system's main menu or through Info mode in the Emacs editor. cws@math.ufl.edu Subject: processes - ps and kill