AMITIAE - Wednesday 3 October 2012
Command Line Work: New Users and Terminal (9) -- Process Identification and Termination |
|
By Graham K. Rogers
The problem may lie not with one of the installed processes but another of the underlying utilities which will not be shown in the list when Force Quit is accessed. Users may need to open a utility (in Applications/Utilities) named Activity Monitor. It is here, for example, that I will come when the Flash Player installation is playing up and the Mac's fans are going wild. It is easy, by highlighting any recalcitrant entry, to quit that and restore peace. Among the data displayed, this lists all the open processes and the resources used. For those not used to such displays, the names of some of the applications may appear strange. Some are helper processes that OS X (with its Unix underpinnings) needs to operate. As well as the Process Name, the first item shown is a PID or process identification number. It is this number that the system needs in order to make the process stop running.
IdentifyAs with the Quit feature in Activity Monitor, it is necessary to identify the process before we can take action using either the kill or killall command. To make this identification we use ps but we need to specifiy parameters. With just ps, only the process being used is identified (the bash shell). To identify all processes being run by the user we use the -u switch, followed by the username (shortname). In my case, this isps -u graham
ps -u admin_name The list starts with the User Identity (UID), followed by the Process identity (PID), the accumulated time (processes are not running continuously) and then the process and its location.
Kill by NumberHaving identified a process we may stop that running by using the kill command. Again, I emphasise the need for care. This is usually done with processes that are specifically focussed on, such as one that the user might have running in Terminal (See Notes, below).To illustrate how kill works, I started the app called DigitalColor Meter that is found in the Utilities folder of Applications. Using the ps command (above: ps -u graham) I identified the PID as 1880 and typed in the command, kill 1880 The process was terminated.
Kill by NameIt may not always be easy for some users to go through the process of identifying a specific application and its PID to use kill. An alternative is to use killall with a specified name. To do this, I began by starting the utility called Grab and simply entering the command,killall Grab stopped the process.
killall DigitalColor\ Meter which stopped the process.
NotesUsing such commands will terminate the application, even if there are processes taking place, so data may be lost if this is not done as a last resort. I chose the two utilities -- DigitalColor Meter and Grab -- precisely for this reason: there were no related processes or data that would be affected when quit in this way.
Graham K. Rogers teaches at the Faculty of Engineering, Mahidol University in Thailand. He wrote in the Bangkok Post, Database supplement on IT subjects. For the last seven years of Database he wrote a column on Apple and Macs. |
|
For further information, e-mail to