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

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

?? library_24.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 4 頁
字號:
  for (p = j->first_process; p; p = p->next)
    if (!p->completed && !p->stopped)
      return 0;
  return 1;
}

/* Return true if all processes in the job have completed.  */
int
job_is_completed (job *j)
{
  process *p;
  
  for (p = j->first_process; p; p = p->next)
    if (!p->completed)
      return 0;
  return 1;
}
</PRE>
<P>
<A NAME="IDX1746"></A>
<A NAME="IDX1747"></A>
<H3><A NAME="SEC419" HREF="library_toc.html#SEC419" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC419">Initializing the Shell</A></H3>
<P>
When a shell program that normally performs job control is started, it
has to be careful in case it has been invoked from another shell that is
already doing its own job control.  
<P>
A subshell that runs interactively has to ensure that it has been placed
in the foreground by its parent shell before it can enable job control
itself.  It does this by getting its initial process group ID with the
<CODE>getpgrp</CODE> function, and comparing it to the process group ID of the
current foreground job associated with its controlling terminal (which
can be retrieved using the <CODE>tcgetpgrp</CODE> function).
<P>
If the subshell is not running as a foreground job, it must stop itself
by sending a <CODE>SIGTTIN</CODE> signal to its own process group.  It may not
arbitrarily put itself into the foreground; it must wait for the user to
tell the parent shell to do this.  If the subshell is continued again,
it should repeat the check and stop itself again if it is still not in
the foreground.
<A NAME="IDX1748"></A>
<P>
Once the subshell has been placed into the foreground by its parent
shell, it can enable its own job control.  It does this by calling
<CODE>setpgid</CODE> to put itself into its own process group, and then
calling <CODE>tcsetpgrp</CODE> to place this process group into the
foreground.
<P>
When a shell enables job control, it should set itself to ignore all the
job control stop signals so that it doesn't accidentally stop itself.
You can do this by setting the action for all the stop signals to
<CODE>SIG_IGN</CODE>.
<P>
A subshell that runs non-interactively cannot and should not support job
control.  It must leave all processes it creates in the same process
group as the shell itself; this allows the non-interactive shell and its
child processes to be treated as a single job by the parent shell.  This
is easy to do--just don't use any of the job control primitives--but
you must remember to make the shell do it.
<P>
Here is the initialization code for the sample shell that shows how to
do all of this.
<P>
<PRE>
/* Keep track of attributes of the shell.  */

#include &#60;sys/types.h&#62;
#include &#60;termios.h&#62;
#include &#60;unistd.h&#62;

pid_t shell_pgid;
struct termios shell_tmodes;
int shell_terminal;
int shell_is_interactive;


/* Make sure the shell is running interactively as the foreground job
   before proceeding. */

void
init_shell ()
{
  
  /* See if we are running interactively.  */
  shell_terminal = STDIN_FILENO;
  shell_is_interactive = isatty (shell_terminal);

  if (shell_is_interactive)
    {
      /* Loop until we are in the foreground.  */
      while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
        kill (- shell_pgid, SIGTTIN);

      /* Ignore interactive and job-control signals.  */
      signal (SIGINT, SIG_IGN);
      signal (SIGQUIT, SIG_IGN);
      signal (SIGTSTP, SIG_IGN);
      signal (SIGTTIN, SIG_IGN);
      signal (SIGTTOU, SIG_IGN);
      signal (SIGCHLD, SIG_IGN);

      /* Put ourselves in our own process group.  */
      shell_pgid = getpid ();
      if (setpgid (shell_pgid, shell_pgid) &#60; 0)
        {
          perror ("Couldn't put the shell in its own process group");
          exit (1);
        }

      /* Grab control of the terminal.  */
      tcsetpgrp (shell_terminal, shell_pgid);

      /* Save default terminal attributes for shell.  */
      tcgetattr (shell_terminal, &#38;shell_tmodes);
    }
}
</PRE>
<P>
<A NAME="IDX1749"></A>
<H3><A NAME="SEC420" HREF="library_toc.html#SEC420" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC420">Launching Jobs</A></H3>
<P>
Once the shell has taken responsibility for performing job control on
its controlling terminal, it can launch jobs in response to commands
typed by the user.
<P>
To create the processes in a process group, you use the same <CODE>fork</CODE>
and <CODE>exec</CODE> functions described in 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>.
Since there are multiple child processes involved, though, things are a
little more complicated and you must be careful to do things in the
right order.  Otherwise, nasty race conditions can result.
<P>
You have two choices for how to structure the tree of parent-child
relationships among the processes.  You can either make all the
processes in the process group be children of the shell process, or you
can make one process in group be the ancestor of all the other processes
in that group.  The sample shell program presented in this chapter uses
the first approach because it makes bookkeeping somewhat simpler.
<A NAME="IDX1750"></A>
<A NAME="IDX1751"></A>
<P>
As each process is forked, it should put itself in the new process group
by calling <CODE>setpgid</CODE>; 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>.  The first
process in the new group becomes its <DFN>process group leader</DFN>, and its
process ID becomes the <DFN>process group ID</DFN> for the group.
<A NAME="IDX1752"></A>
<P>
The shell should also call <CODE>setpgid</CODE> to put each of its child
processes into the new process group.  This is because there is a
potential timing problem: each child process must be put in the process
group before it begins executing a new program, and the shell depends on
having all the child processes in the group before it continues
executing.  If both the child processes and the shell call
<CODE>setpgid</CODE>, this ensures that the right things happen no matter which
process gets to it first.
<P>
If the job is being launched as a foreground job, the new process group
also needs to be put into the foreground on the controlling terminal
using <CODE>tcsetpgrp</CODE>.  Again, this should be done by the shell as well
as by each of its child processes, to avoid race conditions.
<P>
The next thing each child process should do is to reset its signal
actions.
<P>
During initialization, the shell process set itself to ignore job
control signals; see 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>.  As a result, any child
processes it creates also ignore these signals by inheritance.  This is
definitely undesirable, so each child process should explicitly set the
actions for these signals back to <CODE>SIG_DFL</CODE> just after it is forked.
<P>
Since shells follow this convention, applications can assume that they
inherit the correct handling of these signals from the parent process.
But every application has a responsibility not to mess up the handling
of stop signals.  Applications that disable the normal interpretation of
the SUSP character should provide some other mechanism for the user to
stop the job.  When the user invokes this mechanism, the program should
send a <CODE>SIGTSTP</CODE> signal to the process group of the process, not
just to the process itself.  See section <A HREF="library_21.html#SEC365" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_21.html#SEC365">Signaling Another Process</A>.
<P>
Finally, each child process should call <CODE>exec</CODE> in the normal way.
This is also the point at which redirection of the standard input and 
output channels should be handled.  See section <A HREF="library_12.html#SEC182" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_12.html#SEC182">Duplicating Descriptors</A>,
for an explanation of how to do this.
<P>
Here is the function from the sample shell program that is responsible
for launching a program.  The function is executed by each child process
immediately after it has been forked by the shell, and never returns.
<P>
<PRE>
void
launch_process (process *p, pid_t pgid,
                int infile, int outfile, int errfile,
                int foreground)
{
  pid_t pid;

  if (shell_is_interactive)
    {
      /* Put the process into the process group and give the process group
         the terminal, if appropriate.
         This has to be done both by the shell and in the individual
         child processes because of potential race conditions.  */
      pid = getpid ();
      if (pgid == 0) pgid = pid;
      setpgid (pid, pgid);
      if (foreground)
        tcsetpgrp (shell_terminal, pgid);

      /* Set the handling for job control signals back to the default.  */
      signal (SIGINT, SIG_DFL);
      signal (SIGQUIT, SIG_DFL);
      signal (SIGTSTP, SIG_DFL);
      signal (SIGTTIN, SIG_DFL);
      signal (SIGTTOU, SIG_DFL);
      signal (SIGCHLD, SIG_DFL);
    }

  /* Set the standard input/output channels of the new process.  */
  if (infile != STDIN_FILENO)
    {
      dup2 (infile, STDIN_FILENO);
      close (infile);
    }
  if (outfile != STDOUT_FILENO)
    {
      dup2 (outfile, STDOUT_FILENO);
      close (outfile);
    }
  if (errfile != STDERR_FILENO)
    {
      dup2 (errfile, STDERR_FILENO);
      close (errfile);
    }    
  
  /* Exec the new process.  Make sure we exit.  */ 
  execvp (p-&#62;argv[0], p-&#62;argv);
  perror ("execvp");
  exit (1);
}
</PRE>
<P>
If the shell is not running interactively, this function does not do
anything with process groups or signals.  Remember that a shell not
performing job control must keep all of its subprocesses in the same
process group as the shell itself.
<P>
Next, here is the function that actually launches a complete job.
After creating the child processes, this function calls some other
functions to put the newly created job into the foreground or background;
these are discussed in 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>.
<P>
<PRE>
void
launch_job (job *j, int foreground)
{
  process *p;
  pid_t pid;
  int mypipe[2], infile, outfile;
  
  infile = j-&#62;stdin;
  for (p = j-&#62;first_process; p; p = p-&#62;next)
    {
      /* Set up pipes, if necessary.  */
      if (p-&#62;next)
        {
          if (pipe (mypipe) &#60; 0)
            {
              perror ("pipe");
              exit (1);
            }
          outfile = mypipe[1];
        }
      else
        outfile = j-&#62;stdout;

      /* Fork the child processes.  */
      pid = fork ();
      if (pid == 0)
        /* This is the child process.  */
        launch_process (p, j-&#62;pgid, infile, outfile, j-&#62;stderr, foreground);
      else if (pid &#60; 0)
        {
          /* The fork failed.  */
          perror ("fork");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
岛国一区二区三区| gogogo免费视频观看亚洲一| 国产精品免费免费| 国产片一区二区| 日本一区二区三级电影在线观看| 国产成人aaaa| 成人深夜福利app| 色综合夜色一区| 欧美日韩精品一区视频| 91精品国产黑色紧身裤美女| 91麻豆精品91久久久久久清纯| 91精品国产综合久久精品图片| 日韩一区二区电影在线| 久久精品人人做人人爽人人| 国产欧美一区二区精品婷婷| 国产片一区二区三区| 亚洲私人黄色宅男| 五月天丁香久久| 国产乱国产乱300精品| 成人激情校园春色| 欧美色图一区二区三区| 欧美一区二区三区小说| 欧美国产日韩a欧美在线观看| 18欧美乱大交hd1984| 三级在线观看一区二区| 国产精品一区二区x88av| 国产成人免费视频一区| 99精品偷自拍| 欧美一区二区三区免费观看视频| 久久精品人人做人人爽97| 亚洲欧美偷拍卡通变态| 国内外成人在线| 欧美午夜精品久久久久久超碰| 精品少妇一区二区三区| 亚洲美女免费视频| 韩国av一区二区三区| 欧美在线观看你懂的| 国产网站一区二区| 偷偷要91色婷婷| 福利电影一区二区| 91精品国产综合久久精品图片 | 91麻豆国产精品久久| 欧美三级视频在线观看| 国产精品青草久久| 全国精品久久少妇| 欧美性猛片xxxx免费看久爱| 国产欧美日韩综合| 精品一区二区成人精品| 欧美日韩午夜在线| 亚洲理论在线观看| 高清在线成人网| 久久女同性恋中文字幕| 日本美女视频一区二区| 精品视频在线视频| 亚洲免费高清视频在线| 成人自拍视频在线观看| 欧美精品一区二区三区蜜桃 | 国产香蕉久久精品综合网| 无码av中文一区二区三区桃花岛| 国产aⅴ精品一区二区三区色成熟| 欧美日韩国产综合一区二区三区| 国产精品电影一区二区三区| 国产一区二区成人久久免费影院 | 亚洲欧美电影一区二区| 成人晚上爱看视频| 久久久精品国产免大香伊| 韩国欧美一区二区| 精品少妇一区二区三区视频免付费 | 国产精品丝袜久久久久久app| 日韩精品一区第一页| 欧美精品色综合| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美性做爰猛烈叫床潮| 亚洲欧美日韩人成在线播放| 国产suv一区二区三区88区| 欧美精品一区二区三区蜜桃视频| 日韩激情视频在线观看| 欧美性大战久久久久久久蜜臀| 国产精品久久久久三级| 国产高清不卡二三区| 精品国精品国产| 国产在线视频一区二区三区| 2欧美一区二区三区在线观看视频| 狠狠色伊人亚洲综合成人| 日韩免费电影网站| 国产一本一道久久香蕉| 国产三级精品视频| 色婷婷综合视频在线观看| 亚洲高清中文字幕| 91精品国产欧美一区二区成人| 久久国产尿小便嘘嘘尿| 国产欧美一区视频| 日本久久电影网| 看片的网站亚洲| 国产欧美综合在线观看第十页| 91在线免费看| 日韩福利电影在线| 欧美国产一区在线| 欧美午夜寂寞影院| 极品少妇一区二区| 亚洲乱码国产乱码精品精小说| 91.com视频| 成人免费看黄yyy456| 亚洲在线视频网站| 精品对白一区国产伦| 99国产精品视频免费观看| 亚洲chinese男男1069| 国产亚洲福利社区一区| 欧美三级日韩三级| 国产成人精品免费网站| 亚洲国产日韩a在线播放| 精品久久人人做人人爱| 在线影视一区二区三区| 国产一区二区三区免费观看| 一区二区三区.www| 精品日产卡一卡二卡麻豆| 波多野结衣亚洲| 精品一二三四在线| 午夜精品久久久久久久| 亚洲欧洲国产日本综合| 欧美刺激午夜性久久久久久久| 91女神在线视频| 国产一区二区三区在线观看精品 | 国产成人精品aa毛片| 丝袜美腿亚洲一区| 亚洲嫩草精品久久| 国产女主播一区| 欧美大黄免费观看| 欧美一区二区三区男人的天堂| 97久久久精品综合88久久| 精品一区二区av| 美女尤物国产一区| 亚洲最快最全在线视频| 26uuu亚洲综合色| 在线国产亚洲欧美| 91尤物视频在线观看| 国产99久久久久| 国产伦理精品不卡| 精品亚洲porn| 日本成人在线电影网| 亚洲电影第三页| 亚洲一级二级三级| 亚洲高清免费视频| 亚洲mv在线观看| 图片区日韩欧美亚洲| 午夜精品久久久久久久久久久| 亚洲综合色自拍一区| 尤物在线观看一区| 一区二区三区精品久久久| 综合久久给合久久狠狠狠97色| 国产精品午夜电影| 国产精品久久99| 亚洲久本草在线中文字幕| 日韩理论片网站| 亚洲精品国产精品乱码不99| 亚洲啪啪综合av一区二区三区| 国产精品欧美久久久久一区二区| 国产日产欧美精品一区二区三区| 欧美精品一区二区三区在线播放 | 国产一区二区0| 国产河南妇女毛片精品久久久| 国产成人在线观看| 成人免费毛片嘿嘿连载视频| 成人激情动漫在线观看| 粉嫩av亚洲一区二区图片| fc2成人免费人成在线观看播放| 91在线小视频| 538在线一区二区精品国产| 日韩欧美一二三| 欧美国产精品久久| 亚洲欧美国产77777| 午夜精品123| 国产一区二区三区高清播放| 99在线视频精品| 欧美日韩大陆在线| 久久精品夜色噜噜亚洲aⅴ| 中文字幕乱码久久午夜不卡| 亚洲一区二区三区四区的| 日本亚洲电影天堂| 成人一级片网址| 欧美日韩精品福利| 久久久久国产精品麻豆| 亚洲一区二区中文在线| 精品一区二区在线观看| 色哟哟国产精品免费观看| 欧美一级欧美三级| 亚洲色图第一区| 久久草av在线| 欧美在线一区二区三区| 精品国产不卡一区二区三区| 亚洲欧美另类小说| 日韩av电影天堂| 国产盗摄一区二区| 色美美综合视频| 欧美精品一区二区三区四区| 亚洲自拍偷拍图区| 国产a级毛片一区| 日韩精品一区国产麻豆| 一区二区三区高清不卡| 国产精品一二三区在线|