亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? library_24.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 4 頁
字號:
<!-- This HTML file has been created by texi2html 1.27
     from library.texinfo on 3 March 1994 -->

<TITLE>The GNU C Library - Job Control</TITLE>
<P>Go to the <A HREF="library_23.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html">previous</A>, <A HREF="library_25.html" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_25.html">next</A> section.<P>
<H1><A NAME="SEC411" HREF="library_toc.html#SEC411" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC411">Job Control</A></H1>
<A NAME="IDX1729"></A>
<A NAME="IDX1730"></A>
<A NAME="IDX1731"></A>
<A NAME="IDX1732"></A>
<P>
<DFN>Job control</DFN> refers to the protocol for allowing a user to move
between multiple <DFN>process groups</DFN> (or <DFN>jobs</DFN>) within a single
<DFN>login session</DFN>.  The job control facilities are set up so that
appropriate behavior for most programs happens automatically and they
need not do anything special about job control.  So you can probably
ignore the material in this chapter unless you are writing a shell or
login program.
<P>
You need to be familiar with concepts relating to process creation
(see section <A HREF="library_23.html#SEC403" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC403">Process Creation Concepts</A>) and signal handling (see section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>) in order to understand this material presented in this
chapter.
<P>
<H2><A NAME="SEC412" HREF="library_toc.html#SEC412" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC412">Concepts of Job Control</A></H2>
<A NAME="IDX1733"></A>
<P>
The fundamental purpose of an interactive shell is to read
commands from the user's terminal and create processes to execute the
programs specified by those commands.  It can do this using the
<CODE>fork</CODE> (see section <A HREF="library_23.html#SEC405" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC405">Creating a Process</A>) and <CODE>exec</CODE>
(see section <A HREF="library_23.html#SEC406" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC406">Executing a File</A>) functions.
<P>
A single command may run just one process--but often one command uses
several processes.  If you use the <SAMP>`|'</SAMP> operator in a shell command,
you explicitly request several programs in their own processes.  But
even if you run just one program, it can use multiple processes
internally.  For example, a single compilation command such as <SAMP>`cc
-c foo.c'</SAMP> typically uses four processes (though normally only two at any
given time).  If you run <CODE>make</CODE>, its job is to run other programs
in separate processes.
<P>
The processes belonging to a single command are called a <DFN>process
group</DFN> or <DFN>job</DFN>.  This is so that you can operate on all of them at
once.  For example, typing <KBD>C-c</KBD> sends the signal <CODE>SIGINT</CODE> to
terminate all the processes in the foreground process group.
<A NAME="IDX1734"></A>
<P>
A <DFN>session</DFN> is a larger group of processes.  Normally all the
proccesses that stem from a single login belong to the same session.
<P>
Every process belongs to a process group.  When a process is created, it
becomes a member of the same process group and session as its parent
process.  You can put it in another process group using the
<CODE>setpgid</CODE> function, provided the process group belongs to the same
session.
<A NAME="IDX1735"></A>
<P>
The only way to put a process in a different session is to make it the
initial process of a new session, or a <DFN>session leader</DFN>, using the
<CODE>setsid</CODE> function.  This also puts the session leader into a new
process group, and you can't move it out of that process group again.
<P>
Usually, new sessions are created by the system login program, and the
session leader is the process running the user's login shell.
<A NAME="IDX1736"></A>
<P>
A shell that supports job control must arrange to control which job can
use the terminal at any time.  Otherwise there might be multiple jobs
trying to read from the terminal at once, and confusion about which
process should receive the input typed by the user.  To prevent this,
the shell must cooperate with the terminal driver using the protocol
described in this chapter.
<A NAME="IDX1737"></A>
<A NAME="IDX1738"></A>
<P>
The shell can give unlimited access to the controlling terminal to only
one process group at a time.  This is called the <DFN>foreground job</DFN> on
that controlling terminal.  Other process groups managed by the shell
that are executing without such access to the terminal are called
<DFN>background jobs</DFN>.
<A NAME="IDX1739"></A>
<P>
If a background job needs to read from or write to its controlling
terminal, it is <DFN>stopped</DFN> by the terminal driver.  The user can stop
a foreground job by typing the SUSP character (see section <A HREF="library_16.html#SEC281" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC281">Special Characters</A>) and a program can stop any job by sending it a
<CODE>SIGSTOP</CODE> signal.  It's the responsibility of the shell to notice
when jobs stop, to notify the user about them, and to provide mechanisms
for allowing the user to interactively continue stopped jobs and switch
jobs between foreground and background.
<P>
See section <A HREF="library_24.html#SEC415" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC415">Access to the Controlling Terminal</A>, for more information about I/O to the
controlling terminal,
<P>
<A NAME="IDX1740"></A>
<H2><A NAME="SEC413" HREF="library_toc.html#SEC413" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC413">Job Control is Optional</A></H2>
<P>
Not all operating systems support job control.  The GNU system does
support job control, but if you are using the GNU library on some other
system, that system may not support job control itself.
<P>
You can use the <CODE>_POSIX_JOB_CONTROL</CODE> macro to test at compile-time
whether the system supports job control.  See section <A HREF="library_27.html#SEC456" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_27.html#SEC456">Overall System Options</A>.
<P>
If job control is not supported, then there can be only one process
group per session, which behaves as if it were always in the foreground.
The functions for creating additional process groups simply fail with
the error code <CODE>ENOSYS</CODE>.
<P>
The macros naming the various job control signals (see section <A HREF="library_21.html#SEC340" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC340">Job Control Signals</A>) are defined even if job control is not supported.  However,
the system never generates these signals, and attempts to send a job
control signal or examine or specify their actions report errors or do
nothing.
<P>
<H2><A NAME="SEC414" HREF="library_toc.html#SEC414" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC414">Controlling Terminal of a Process</A></H2>
<P>
One of the attributes of a process is its controlling terminal.  Child
processes created with <CODE>fork</CODE> inherit the controlling terminal from
their parent process.  In this way, all the processes in a session
inherit the controlling terminal from the session leader.  A session
leader that has control of a terminal is called the <DFN>controlling
process</DFN> of that terminal.
<A NAME="IDX1741"></A>
<P>
You generally do not need to worry about the exact mechanism used to
allocate a controlling terminal to a session, since it is done for you
by the system when you log in.
<P>
An individual process disconnects from its controlling terminal when it
calls <CODE>setsid</CODE> to become the leader of a new session.
See section <A HREF="library_24.html#SEC427" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC427">Process Group Functions</A>.
<P>
<A NAME="IDX1742"></A>
<H2><A NAME="SEC415" HREF="library_toc.html#SEC415" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC415">Access to the Controlling Terminal</A></H2>
<P>
Processes in the foreground job of a controlling terminal have
unrestricted access to that terminal; background proesses do not.  This
section describes in more detail what happens when a process in a
background job tries to access its controlling terminal.
<A NAME="IDX1743"></A>
<P>
When a process in a background job tries to read from its controlling
terminal, the process group is usually sent a <CODE>SIGTTIN</CODE> signal.
This normally causes all of the processes in that group to stop (unless
they handle the signal and don't stop themselves).  However, if the
reading process is ignoring or blocking this signal, then <CODE>read</CODE>
fails with an <CODE>EIO</CODE> error instead.
<A NAME="IDX1744"></A>
<P>
Similarly, when a process in a background job tries to write to its
controlling terminal, the default behavior is to send a <CODE>SIGTTOU</CODE>
signal to the process group.  However, the behavior is modified by the
<CODE>TOSTOP</CODE> bit of the local modes flags (see section <A HREF="library_16.html#SEC279" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC279">Local Modes</A>).  If
this bit is not set (which is the default), then writing to the
controlling terminal is always permitted without sending a signal.
Writing is also permitted if the <CODE>SIGTTOU</CODE> signal is being ignored
or blocked by the writing process.
<P>
Most other terminal operations that a program can do are treated as
reading or as writing.  (The description of each operation should say
which.)
<P>
For more information about the primitive <CODE>read</CODE> and <CODE>write</CODE>
functions, see section <A HREF="library_12.html#SEC173" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC173">Input and Output Primitives</A>.
<P>
<A NAME="IDX1745"></A>
<H2><A NAME="SEC416" HREF="library_toc.html#SEC416" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC416">Orphaned Process Groups</A></H2>
<P>
When a controlling process terminates, its terminal becomes free and a
new session can be established on it.  (In fact, another user could log
in on the terminal.)  This could cause a problem if any processes from
the old session are still trying to use that terminal.
<P>
To prevent problems, process groups that continue running even after the
session leader has terminated are marked as <DFN>orphaned process
groups</DFN>.  Processes in an orphaned process group cannot read from or
write to the controlling terminal.  Attempts to do so will fail with an
<CODE>EIO</CODE> error.
<P>
When a process group becomes an orphan, its processes are sent a
<CODE>SIGHUP</CODE> signal.  Ordinarily, this causes the processes to
terminate.  However, if a program ignores this signal or establishes a
handler for it (see section <A HREF="library_21.html#SEC330" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC330">Signal Handling</A>), it can continue running as in
the orphan process group even after its controlling process terminates;
but it still cannot access the terminal any more.
<P>
<H2><A NAME="SEC417" HREF="library_toc.html#SEC417" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC417">Implementing a Job Control Shell</A></H2>
<P>
This section describes what a shell must do to implement job control, by
presenting an extensive sample program to illustrate the concepts
involved.
<P>
<UL>
<LI>
section <A HREF="library_24.html#SEC418" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC418">Data Structures for the Shell</A>, introduces the example and presents
its primary data structures.
<P>
<LI>
section <A HREF="library_24.html#SEC419" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC419">Initializing the Shell</A>, discusses actions which the shell must
perform to prepare for job control.
<P>
<LI>
section <A HREF="library_24.html#SEC420" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC420">Launching Jobs</A>, includes information about how to create jobs
to execute commands.
<P>
<LI>
section <A HREF="library_24.html#SEC421" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC421">Foreground and Background</A>, discusses what the shell should
do differently when launching a job in the foreground as opposed to
a background job.
<P>
<LI>
section <A HREF="library_24.html#SEC422" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC422">Stopped and Terminated Jobs</A>, discusses reporting of job status
back to the shell.
<P>
<LI>
section <A HREF="library_24.html#SEC423" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC423">Continuing Stopped Jobs</A>, tells you how to continue jobs that
have been stopped.
<P>
<LI>
section <A HREF="library_24.html#SEC424" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC424">The Missing Pieces</A>, discusses other parts of the shell.
</UL>
<P>
<H3><A NAME="SEC418" HREF="library_toc.html#SEC418" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC418">Data Structures for the Shell</A></H3>
<P>
All of the program examples included in this chapter are part of
a simple shell program.  This section presents data structures
and utility functions which are used throughout the example.
<P>
The sample shell deals mainly with two data structures.  The
<CODE>job</CODE> type contains information about a job, which is a
set of subprocesses linked together with pipes.  The <CODE>process</CODE> type
holds information about a single subprocess.  Here are the relevant
data structure declarations:
<P>
<PRE>
/* A process is a single process.  */
typedef struct process
{
  struct process *next;       /* next process in pipeline */
  char **argv;                /* for exec */
  pid_t pid;                  /* process ID */
  char completed;             /* true if process has completed */
  char stopped;               /* true if process has stopped */
  int status;                 /* reported status value */
} process;

/* A job is a pipeline of processes.  */
typedef struct job
{
  struct job *next;           /* next active job */
  char *command;              /* command line, used for messages */
  process *first_process;     /* list of processes in this job */
  pid_t pgid;                 /* process group ID */
  char notified;              /* true if user told about stopped job */
  struct termios tmodes;      /* saved terminal modes */
  int stdin, stdout, stderr;  /* standard i/o channels */
} job;

/* The active jobs are linked into a list.  This is its head.   */
job *first_job = NULL;
</PRE>
<P>
Here are some utility functions that are used for operating on <CODE>job</CODE>
objects.
<P>
<PRE>
/* Find the active job with the indicated <VAR>pgid</VAR>.  */
job *
find_job (pid_t pgid)
{
  job *j;
  
  for (j = first_job; j; j = j-&#62;next)
    if (j-&#62;pgid == pgid)
      return j;
  return NULL;
}

/* Return true if all processes in the job have stopped or completed.  */
int
job_is_stopped (job *j)
{
  process *p;
  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩久久久久久| 中文字幕日韩精品一区| 亚洲日本在线a| 久久精品国产久精国产爱| 在线观看视频一区| 中文字幕不卡一区| 黄色小说综合网站| 欧美日韩国产123区| 日韩毛片精品高清免费| 精久久久久久久久久久| 6080日韩午夜伦伦午夜伦| 中文字幕一区二区在线观看| 青娱乐精品在线视频| 在线亚洲精品福利网址导航| 国产精品短视频| 国产成都精品91一区二区三| 日韩欧美一区电影| 三级一区在线视频先锋| 欧美视频一区二区三区| 亚洲精品伦理在线| 色综合天天在线| 国产精品久久网站| 国产v综合v亚洲欧| 国产视频视频一区| 国产福利91精品一区| 久久久一区二区三区| 激情六月婷婷久久| 久久久精品免费观看| 国产精品中文字幕欧美| 久久新电视剧免费观看| 国产精品一区二区x88av| 久久久久88色偷偷免费| 高清日韩电视剧大全免费| 久久网站热最新地址| 国产在线视频一区二区| 久久精品网站免费观看| 盗摄精品av一区二区三区| 欧美精彩视频一区二区三区| 国产69精品久久久久毛片| 国产日产欧美一区| 成人三级伦理片| 亚洲人一二三区| 色久优优欧美色久优优| 亚洲高清免费视频| 91精品国产一区二区三区蜜臀| 日产国产欧美视频一区精品| 日韩女优制服丝袜电影| 国产成人免费xxxxxxxx| 日韩美女精品在线| 91精品国产综合久久小美女| 国产在线国偷精品产拍免费yy| 久久久久久麻豆| 色综合婷婷久久| 日本伊人色综合网| 久久精品男人的天堂| 91污在线观看| 首页国产欧美久久| 久久综合视频网| 97久久精品人人做人人爽50路| 亚洲国产精品久久不卡毛片| 日韩欧美色综合| 91在线视频观看| 免费人成在线不卡| 国产精品欧美一区二区三区| 欧美在线你懂得| 国产乱淫av一区二区三区 | 亚洲综合免费观看高清在线观看| 欧美日韩卡一卡二| 国产成人精品亚洲午夜麻豆| 亚洲影视在线播放| 国产欧美日韩在线| 欧美精品xxxxbbbb| 不卡在线视频中文字幕| 日韩和的一区二区| 国产精品乱人伦一区二区| 欧美日韩一级黄| 成人手机电影网| 久久不见久久见免费视频1| 亚洲人精品午夜| 国产亚洲午夜高清国产拍精品| 在线精品视频一区二区| 国产成人三级在线观看| 午夜视黄欧洲亚洲| 亚洲三级在线看| 久久日一线二线三线suv| 欧美专区日韩专区| www.欧美日韩| 国产一区二区三区日韩| 首页国产丝袜综合| 一区二区在线观看视频| 久久精品网站免费观看| 日韩欧美成人一区| 欧美乱妇15p| 色成人在线视频| 99久久综合色| 丁香六月综合激情| 国产成人在线观看免费网站| 麻豆91在线观看| 日韩av一区二区在线影视| 亚洲一区二区av在线| 亚洲天堂av老司机| 国产精品全国免费观看高清| 久久久国产一区二区三区四区小说| 欧美美女一区二区三区| 在线中文字幕不卡| 色菇凉天天综合网| 色综合久久久久久久久| 99精品视频在线观看免费| 成人午夜精品一区二区三区| 国产一区二区在线视频| 精品一区二区三区的国产在线播放| 日韩综合一区二区| 日本中文在线一区| 美女mm1313爽爽久久久蜜臀| 亚洲成av人片www| 亚洲动漫第一页| 日韩制服丝袜av| 日产欧产美韩系列久久99| 日韩精品一二三四| 免费不卡在线视频| 国产真实乱对白精彩久久| 国产成人在线免费观看| 丁香激情综合五月| 色婷婷综合中文久久一本| 91麻豆精东视频| 欧美熟乱第一页| 欧美成人aa大片| 国产午夜精品久久久久久免费视 | 亚洲免费在线视频一区 二区| 亚洲同性同志一二三专区| 亚洲区小说区图片区qvod| 亚洲国产欧美另类丝袜| 日韩精品乱码av一区二区| 久久精品72免费观看| 国产精品1区2区| 色婷婷国产精品| 91精品国产免费| 欧美国产日产图区| 亚洲在线观看免费视频| 欧美bbbbb| 波多野结衣的一区二区三区| 欧美日韩免费观看一区二区三区| 日韩视频免费观看高清完整版在线观看 | 污片在线观看一区二区| 精品系列免费在线观看| 99精品偷自拍| 69久久99精品久久久久婷婷| 国产日韩亚洲欧美综合| 亚洲影院理伦片| 国产精品综合二区| 欧美三级电影在线看| 2024国产精品| 一区二区三区中文在线观看| 美女视频免费一区| 成人小视频在线| 日韩一区国产二区欧美三区| 日本一区二区视频在线| 香蕉久久一区二区不卡无毒影院| 国产一区二区三区在线看麻豆| 99精品国产99久久久久久白柏| 欧美顶级少妇做爰| 亚洲欧洲精品成人久久奇米网| 日韩av电影天堂| 91成人看片片| 国产精品久久久久久久久搜平片 | 最新欧美精品一区二区三区| 日本vs亚洲vs韩国一区三区二区| 99久久精品国产一区| 欧美成人一区二区三区在线观看| 玉足女爽爽91| 97久久精品人人做人人爽| 久久久久久久性| 久久99久久精品欧美| 欧美精品亚洲一区二区在线播放| 亚洲欧洲av在线| 丁香啪啪综合成人亚洲小说| 精品国产一区二区三区久久影院| 亚洲大片一区二区三区| 91美女蜜桃在线| 国产精品久久久久精k8| 国产黄色精品视频| 2017欧美狠狠色| 国产在线麻豆精品观看| 欧美一级久久久久久久大片| 亚洲电影一区二区三区| 在线免费观看一区| 亚洲少妇30p| 成人免费高清在线| 亚洲国产成人一区二区三区| 韩国一区二区视频| 久久在线观看免费| 国产伦理精品不卡| 久久久国产精华| 大美女一区二区三区| 国产精品午夜久久| 成人免费视频一区二区| 自拍偷拍亚洲欧美日韩| 一本一道波多野结衣一区二区 | 97成人超碰视| 亚洲人123区|