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

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

?? library_24.html

?? linux_c函數,linux下編程必備的
?? 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一区二区三区免费野_久草精品视频
五月婷婷色综合| 亚洲一区在线观看视频| 3d成人h动漫网站入口| 色婷婷av一区| 欧美专区在线观看一区| 色94色欧美sute亚洲13| 色综合av在线| 欧美无砖专区一中文字| 91成人网在线| 欧美三级欧美一级| 欧美一级一级性生活免费录像| 欧美三级蜜桃2在线观看| 欧美日韩精品一区二区天天拍小说 | 在线不卡一区二区| 在线视频你懂得一区二区三区| 色av一区二区| 在线成人免费观看| 久久综合一区二区| 国产欧美日韩三区| 亚洲人成影院在线观看| 一区二区中文视频| 亚洲午夜一区二区三区| 日韩av高清在线观看| 精品午夜一区二区三区在线观看 | 男人操女人的视频在线观看欧美| 日韩高清在线一区| 国产精品资源网| 99re热视频精品| 欧美高清视频一二三区 | 中文字幕一区二区三区在线观看 | 日韩免费看的电影| 日本一区二区三区国色天香 | 婷婷开心激情综合| 激情综合色播激情啊| 国产成人精品一区二区三区四区| 成av人片一区二区| 欧美高清hd18日本| 欧美国产一区视频在线观看| 亚洲综合丝袜美腿| 国产原创一区二区| 欧美午夜不卡在线观看免费| 久久亚洲免费视频| 亚洲丶国产丶欧美一区二区三区| 韩国三级在线一区| 精品视频在线免费观看| xfplay精品久久| 一区二区三区免费在线观看| 国产综合色在线| 色88888久久久久久影院按摩| 日韩欧美成人激情| 伊人开心综合网| 国产91露脸合集magnet| 91麻豆精品国产91久久久更新时间| 国产亚洲短视频| 日韩电影在线一区二区三区| 99久久精品国产观看| 久久综合精品国产一区二区三区| 亚洲一区二区三区四区在线免费观看 | 在线电影欧美成精品| 亚洲人成亚洲人成在线观看图片| 久久www免费人成看片高清| 色屁屁一区二区| 欧美高清在线精品一区| 国内精品伊人久久久久av一坑| 欧美自拍偷拍一区| 亚洲欧美福利一区二区| jlzzjlzz欧美大全| 欧美激情在线观看视频免费| 捆绑变态av一区二区三区| 欧美无砖砖区免费| 亚洲亚洲精品在线观看| 色婷婷国产精品综合在线观看| 国产精品三级在线观看| 国产成人亚洲综合a∨婷婷图片| 精品处破学生在线二十三| 久久精品久久99精品久久| 欧美一二三四在线| 另类调教123区 | 欧美国产1区2区| 国产成人精品一区二区三区网站观看| 日韩色视频在线观看| 九色综合狠狠综合久久| www欧美成人18+| 国产成人精品一区二| 国产精品视频一二三区| 成人精品在线视频观看| 1区2区3区精品视频| 91玉足脚交白嫩脚丫在线播放| 国产精品免费视频网站| 91片在线免费观看| 亚洲国产精品嫩草影院| 欧美精品丝袜久久久中文字幕| 青青草国产精品97视觉盛宴| 91精品国产手机| 国产精品123| 亚洲天堂中文字幕| 欧美电影影音先锋| 国产一区二区精品久久| 亚洲天堂av老司机| 3d动漫精品啪啪1区2区免费 | 日本一区二区免费在线观看视频 | 亚洲精品少妇30p| 欧美日韩国产综合草草| 激情综合色播激情啊| 国产精品久久久一本精品| 欧美在线一区二区三区| 久久99热狠狠色一区二区| 国产精品不卡在线| 91精品国产91久久久久久一区二区| 黄色精品一二区| 亚洲人123区| 日韩欧美一二三区| 91丝袜美腿高跟国产极品老师 | 久久一区二区三区国产精品| 99精品热视频| 免费人成精品欧美精品| 国产精品蜜臀在线观看| 欧美日韩精品一区二区三区四区| 国产宾馆实践打屁股91| 婷婷综合五月天| 国产精品美女久久久久久久久| 欧美日韩中字一区| 成人免费不卡视频| 国产一区亚洲一区| 亚洲第一成人在线| 国产精品欧美久久久久无广告| 7777精品伊人久久久大香线蕉超级流畅 | 亚洲免费观看高清完整版在线 | 国产精华液一区二区三区| 亚洲成人激情av| 国产精品福利电影一区二区三区四区| 欧美精品一二三区| 欧美亚洲禁片免费| 99久久国产综合精品麻豆 | 亚洲精品一区二区三区精华液| 色综合天天视频在线观看| 激情欧美一区二区三区在线观看| 亚洲444eee在线观看| 亚洲三级在线播放| 中文字幕一区视频| 中文字幕成人av| 国产欧美精品一区| 久久久久久久久岛国免费| 日韩精品自拍偷拍| 日韩一区二区三区在线| 欧美日韩高清在线| 欧美日韩夫妻久久| 欧美日韩一级二级三级| 在线区一区二视频| 色偷偷成人一区二区三区91| av午夜一区麻豆| 99久久99久久久精品齐齐| 92国产精品观看| 91在线国产观看| 色欧美乱欧美15图片| 91麻豆福利精品推荐| 99久久久无码国产精品| 97se亚洲国产综合在线| 91老师片黄在线观看| 99精品国产一区二区三区不卡| 国产+成+人+亚洲欧洲自线| 国产69精品久久久久毛片| 成人久久久精品乱码一区二区三区| 国产成都精品91一区二区三| 狠狠色综合日日| 国产成人精品三级麻豆| 成人福利视频网站| 色综合久久久久久久久久久| 91福利精品视频| 欧美一区午夜精品| 久久久亚洲欧洲日产国码αv| 国产亚洲一区二区三区| 国产欧美精品区一区二区三区 | 久久99久久99精品免视看婷婷 | 波多野结衣一区二区三区| a在线欧美一区| 欧美在线不卡视频| 日韩午夜激情视频| 久久精品视频一区二区| 亚洲黄色小视频| 日韩国产在线观看| 国产69精品久久久久毛片| 日本久久电影网| 精品国产乱码久久久久久久久| 国产午夜三级一区二区三| 一区二区三区.www| 麻豆精品一区二区综合av| 丁香桃色午夜亚洲一区二区三区| 色天使色偷偷av一区二区| 精品少妇一区二区三区视频免付费| 中文字幕第一页久久| 午夜伊人狠狠久久| 成人性视频网站| 在线电影国产精品| 中文字幕中文字幕一区| 免费精品99久久国产综合精品| 成人手机在线视频| 日韩午夜精品电影| 亚洲宅男天堂在线观看无病毒| 精品综合久久久久久8888|