< Day Day Up > |
8.1. Process IDs and Job NumbersUNIX gives all processes numbers, called process IDs, when they are created. You will notice that when you run a command in the background by appending & to it, the shell responds with a line that looks like this: $ alice &[1] 93 In this example, 93 is the process ID for the alice process. The [1] is a job number assigned by the shell (not the operating system). What's the difference? Job numbers refer to background processes that are currently running under your shell, while process IDs refer to all processes currently running on the entire system, for all users. The term job basically refers to a command line that was invoked from your shell. If you start up additional background jobs while the first one is still running, the shell will number them 2, 3, etc. For example: $ duchess &[2] 102 $ hatter &[3] 104 Clearly, 1, 2, and 3 are easier to remember than 93, 102, and 104! The shell includes job numbers in messages it prints when a background job completes:[1]
[1]+ Done alice We'll explain what the plus sign means soon. If the job exits with non-zero status (see Chapter 5), the shell will indicate the exit status:[2]
[1]+ Exit 1 alice The shell prints other types of messages when certain abnormal things happen to background jobs; we'll see these later in this chapter. |
< Day Day Up > |