Sophie

Sophie

distrib > Mandriva > 8.1 > i586 > by-pkgid > 628e26a49117deea42e952d5b0d0f0d7 > files > 72

zsh-doc-4.0.2-2mdk.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from ./zsh.texi on 26 June 2001 -->

<TITLE>zsh - Jobs &#38; Signals</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_8.html">previous</A>, <A HREF="zsh_10.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC34" HREF="zsh_toc.html#TOC34">Jobs &#38; Signals</A></H1>
<P>




<H2><A NAME="SEC35" HREF="zsh_toc.html#TOC35">Jobs</A></H2>
<P>
<A NAME="IDX100"></A>
If the <TT>MONITOR</TT> option is set,
an interactive shell associates a <EM>job</EM> with each pipeline.
It keeps a table of current jobs, printed by the <TT>jobs</TT>
command, and assigns them small integer numbers.
When a job is started asynchronously with `<TT>&#38;</TT>',
the shell prints a line which looks like:


<P>

<PRE>
[1] 1234
</PRE>

<P>
indicating that the job which was started asynchronously was job number
1 and had one (top-level) process, whose process ID was 1234.


<P>
If a job is started with `<TT>&#38;|</TT>' or `<TT>&#38;!</TT>',
then that job is immediately disowned.  After startup, it
does not have a place in the job table, and is not subject
to the job control features described here.


<P>
If you are running a job and wish to do something else you may hit the key
^Z (control-Z) which sends a <TT>TSTP</TT> signal to the current job:  this key
may be redefined by the <TT>susp</TT> option of the external <TT>stty</TT> command.
<A NAME="IDX101"></A>
<A NAME="IDX102"></A>
The shell will then normally indicate that the job has been `suspended',
and print another prompt.  You can then manipulate the state of this job,
<A NAME="IDX103"></A>
putting it in the background with the <TT>bg</TT> command, or run some other
commands and then eventually bring the job back into the foreground with
<A NAME="IDX104"></A>
the foreground command <TT>fg</TT>.  A ^Z takes effect immediately and
is like an interrupt in that pending output and unread input are discarded
when it is typed.


<P>
A job being run in the background will suspend if it tries to read
from the terminal.
<A NAME="IDX105"></A>
<A NAME="IDX106"></A>
Background jobs are normally allowed to produce output,
but this can be disabled by giving the command `<TT>stty tostop</TT>'.
If you set this
tty option, then background jobs will suspend when they try to produce
output like they do when they try to read input.


<P>
When a command is suspended and continued later with the <TT>fg</TT> or
<TT>wait</TT> builtins, zsh restores tty modes that were in effect when it was
suspended.  This (intentionally) does not apply if the command is
continued via `<TT>kill -CONT</TT>', nor when it is continued with <TT>bg</TT>.


<P>
<A NAME="IDX107"></A>
<A NAME="IDX108"></A>
There are several ways to refer to jobs in the shell.
A job can be referred to by the process ID of any process of the job
or by one of the following:


<P>
<DL COMPACT>

<DT><TT>%</TT><VAR>number</VAR>
<DD>
The job with the given number.
<DT><TT>%</TT><VAR>string</VAR>
<DD>
Any job whose command line begins with <VAR>string</VAR>.
<DT><TT>%?</TT><VAR>string</VAR>
<DD>
Any job whose command line contains <VAR>string</VAR>.
<DT><TT>%%</TT>
<DD>
Current job.
<DT><TT>%+</TT>
<DD>
Equivalent to `<TT>%%</TT>'.
<DT><TT>%-</TT>
<DD>
Previous job.
</DL>

<P>
The shell learns immediately whenever a process changes state.
<A NAME="IDX109"></A>
It normally informs you whenever a job becomes blocked so that
no further progress is possible.  If the <TT>NOTIFY</TT> option is not set,
it waits until just before it prints a prompt before it informs you.


<P>
When the monitor mode is on, each background job that completes
triggers any trap set for <TT>CHLD</TT>.


<P>
When you try to leave the shell while jobs are running or suspended, you will
be warned that `You have suspended (running) jobs'.
You may use the <TT>jobs</TT> command to see what they are.
If you do this or immediately try to
exit again, the shell will not warn you a second time; the suspended
jobs will be terminated, and the running jobs will be sent
a <TT>SIGHUP</TT> signal, if the <TT>HUP</TT> option is set.
<A NAME="IDX110"></A>


<P>
<A NAME="IDX111"></A>
<A NAME="IDX112"></A>
<A NAME="IDX113"></A>
To avoid having the shell terminate the running jobs, either
use the <CITE>nohup</CITE> command (see man page nohup(1))
or the <TT>disown</TT> builtin.




<H2><A NAME="SEC36" HREF="zsh_toc.html#TOC36">Signals</A></H2>
<P>
The <TT>INT</TT> and <TT>QUIT</TT> signals for an invoked
command are ignored if the command is followed by
`<TT>&#38;</TT>' and the <TT>MONITOR</TT> option is not active.
Otherwise, signals have the values
inherited by the shell from its parent
(but see the <TT>TRAP</TT><VAR>NAL</VAR> special functions in section <A HREF="zsh_8.html#SEC31">Functions</A>).


<P><HR><P>
Go to the <A HREF="zsh_1.html">first</A>, <A HREF="zsh_8.html">previous</A>, <A HREF="zsh_10.html">next</A>, <A HREF="zsh_29.html">last</A> section, <A HREF="zsh_toc.html">table of contents</A>.
</BODY>
</HTML>