jobs - display status of jobs in the current session
The jobs utility shall display the status of jobs that were started in the current shell environment; see Shell Execution Environment .
When jobs reports the termination status of a job, the shell shall remove its process ID from the list of those "known in the current shell execution environment''; see Asynchronous Lists .
The jobs utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported:
By default, the jobs utility shall display the status of all stopped jobs, running background jobs and all jobs whose status has changed and have not been reported by the shell.
The following operand shall be supported:
The following environment variables shall affect the execution of jobs:
If the -p option is specified, the output shall consist of one line for each process ID:
"%d\n", <process ID>
Otherwise, if the -l option is not specified, the output shall be a series of lines of the form:
"[%d] %c %s %s\n", <job-number>, <current>, <state>, <command>
where the fields shall be as follows:
Indicates that the job was suspended by the SIGTSTP signal.
Indicates that the job was suspended by the SIGSTOP signal.
Indicates that the job was suspended by the SIGTTIN signal.
Indicates that the job was suspended by the SIGTTOU signal.
The implementation may substitute the string Suspended in place of Stopped. If the job was terminated by a signal, the format of <state> is unspecified, but it shall be visibly distinct from all of the other <state> formats shown here and shall indicate the name or description of the signal causing the termination.
If the -l option is specified, a field containing the process group ID shall be inserted before the <state> field. Also, more processes in a process group may be output on separate lines, using only the process ID and <command> fields.
The standard error shall be used only for diagnostic messages.
The following exit values shall be returned:
Default.
The following sections are informative.
The -p option is the only portable way to find out the process group of a job because different implementations have different strategies for defining the process group of the job. Usage such as $( jobs -p) provides a way of referring to the process group of the job in an implementation-independent way.
The jobs utility does not work as expected when it is operating in its own utility execution environment because that environment has no applicable jobs to manipulate. See the APPLICATION USAGE section for bg . For this reason, jobs is generally implemented as a shell regular built-in.
Both "%%" and "%+" are used to refer to the current job. Both forms are of equal validity-the "%%" mirroring "$$" and "%+" mirroring the output of jobs. Both forms reflect historical practice of the KornShell and the C shell with job control.
The job control features provided by bg, fg, and jobs are based on the KornShell. The standard developers examined the characteristics of the C shell versions of these utilities and found that differences exist. Despite widespread use of the C shell, the KornShell versions were selected for this volume of IEEE Std 1003.1-2001 to maintain a degree of uniformity with the rest of the KornShell features selected (such as the very popular command line editing features).
The jobs utility is not dependent on the job control option, as are the seemingly related bg and fg utilities because jobs is useful for examining background jobs, regardless of the condition of job control. When the user has invoked a set +m command and job control has been turned off, jobs can still be used to examine the background jobs associated with that current session. Similarly, kill can then be used to kill background jobs with kill% <background job number>.
The output for terminated jobs is left unspecified to accommodate various historical systems. The following formats have been witnessed:
Killed( signal name)
signal name
signal name( coredump)
signal description- core dumped
Most users should be able to understand these formats, although it means that applications have trouble parsing them.
The calculation of job IDs was not described since this would suggest an implementation, which may impose unnecessary restrictions.
In an early proposal, a -n option was included to "Display the status of jobs that have changed, exited, or stopped since the last status report". It was removed because the shell always writes any changed status of jobs before each prompt.
Shell Execution Environment , bg , fg , kill() , wait()
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |