1. Does the shell allocates a job ID to all processes(foreground and background)?

  2. jobs command shows the existing background jobs. How do we see job ID of foreground process?

  3. I want to use a function in C (like getpid()) to get the job ID and status of a given process given the pid of the process.

  4. What is the maximum value of a job ID?

+2  A: 

Job control is a shell feature, not an OS level feature such as processes are.

  1. Job identifiers are assigned when job control is invoked, e.g. with suspend-character (usually Ctrl-Z) or by issuing an & ampersand at the end of command line.

  2. Foreground process gets a job ID only when you suspend it. The shell outputs the job ID for you when suspending.

  3. You can't, since you're not working in the shell anymore.

  4. I'd suspect you run out of other resources first before running out of job IDs.


Job id is differnt from the process and parent process id. The above definion is not much clearly explained aoubt the job id