blob: 605d9f9811d5fa64242b9f0125e1eea99bfc9b12 [file] [log] [blame]
<html lang="en">
<head>
<title>Missing Pieces - The GNU C Library</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="The GNU C Library">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Implementing-a-Shell.html#Implementing-a-Shell" title="Implementing a Shell">
<link rel="prev" href="Continuing-Stopped-Jobs.html#Continuing-Stopped-Jobs" title="Continuing Stopped Jobs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU C library.
This is Edition 0.12, last updated 2007-10-27,
of `The GNU C Library Reference Manual', for version
2.8 (Sourcery G++ Lite 2011.03-41).
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
2003, 2007, 2008, 2010 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software Needs Free Documentation''
and ``GNU Lesser General Public License'', the Front-Cover texts being
``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A
copy of the license is included in the section entitled "GNU Free
Documentation License".
(a) The FSF's Back-Cover Text is: ``You have the freedom to
copy and modify this GNU manual. Buying copies from the FSF
supports it in developing GNU and promoting software freedom.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="Missing-Pieces"></a>
<p>
Previous:&nbsp;<a rel="previous" accesskey="p" href="Continuing-Stopped-Jobs.html#Continuing-Stopped-Jobs">Continuing Stopped Jobs</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Implementing-a-Shell.html#Implementing-a-Shell">Implementing a Shell</a>
<hr>
</div>
<h4 class="subsection">27.6.7 The Missing Pieces</h4>
<p>The code extracts for the sample shell included in this chapter are only
a part of the entire shell program. In particular, nothing at all has
been said about how <code>job</code> and <code>program</code> data structures are
allocated and initialized.
<p>Most real shells provide a complex user interface that has support for
a command language; variables; abbreviations, substitutions, and pattern
matching on file names; and the like. All of this is far too complicated
to explain here! Instead, we have concentrated on showing how to
implement the core process creation and job control functions that can
be called from such a shell.
<p>Here is a table summarizing the major entry points we have presented:
<dl>
<dt><code>void init_shell (void)</code><dd>Initialize the shell's internal state. See <a href="Initializing-the-Shell.html#Initializing-the-Shell">Initializing the Shell</a>.
<br><dt><code>void launch_job (job *</code><var>j</var><code>, int </code><var>foreground</var><code>)</code><dd>Launch the job <var>j</var> as either a foreground or background job.
See <a href="Launching-Jobs.html#Launching-Jobs">Launching Jobs</a>.
<br><dt><code>void do_job_notification (void)</code><dd>Check for and report any jobs that have terminated or stopped. Can be
called synchronously or within a handler for <code>SIGCHLD</code> signals.
See <a href="Stopped-and-Terminated-Jobs.html#Stopped-and-Terminated-Jobs">Stopped and Terminated Jobs</a>.
<br><dt><code>void continue_job (job *</code><var>j</var><code>, int </code><var>foreground</var><code>)</code><dd>Continue the job <var>j</var>. See <a href="Continuing-Stopped-Jobs.html#Continuing-Stopped-Jobs">Continuing Stopped Jobs</a>.
</dl>
<p>Of course, a real shell would also want to provide other functions for
managing jobs. For example, it would be useful to have commands to list
all active jobs or to send a signal (such as <code>SIGKILL</code>) to a job.
</body></html>