Sophie

Sophie

distrib > Mandriva > 9.1 > i586 > by-pkgid > 0195c26144d6a6d8437da6bf9d0aeff3 > files > 90

zsh-doc-4.1.0-0.dev5.4mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                      "http://www.w3.org/TR/html40/loose.dtd">
<HTML>
<!-- Created on August, 9 2002 by texi2html 1.65 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>

-->
<HEAD>
<TITLE>zsh: Jobs &amp; Signals</TITLE>

<META NAME="description" CONTENT="zsh: Jobs &amp; Signals">
<META NAME="keywords" CONTENT="zsh: Jobs &amp; Signals">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.65">

</HEAD>

<BODY LANG="en" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC34"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_8.html#SEC33"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC35"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_8.html#SEC31"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_10.html#SEC37"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H1> 9. Jobs &amp; Signals </H1>
<!--docid::SEC34::-->
<P>

<HR SIZE="6">
<A NAME="SEC35"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC34"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC36"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC34"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_10.html#SEC37"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 9.1 Jobs </H2>
<!--docid::SEC35::-->
<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>&amp;</TT>',
the shell prints a line which looks like:
<P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>[1] 1234
</pre></td></tr></table><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>
<P>

If a job is started with `<TT>&amp;|</TT>' or `<TT>&amp;!</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>
<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>
<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>
<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>
<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>
<P>

</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>
<P>

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

<HR SIZE="6">
<A NAME="SEC36"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC35"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_10.html#SEC37"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC34"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_10.html#SEC37"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<H2> 9.2 Signals </H2>
<!--docid::SEC36::-->
The <TT>INT</TT> and <TT>QUIT</TT> signals for an invoked
command are ignored if the command is followed by
`<TT>&amp;</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 <A HREF="zsh_8.html#SEC31">8. Functions</A>).
<A NAME="Arithmetic Evaluation"></A>
<P>

<HR SIZE="6">
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_9.html#SEC34"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_10.html#SEC37"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_24.html#SEC195">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="zsh_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
by <I>Peter Stephenson</I> on <I>August, 9 2002</I>
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</FONT>

</BODY>
</HTML>