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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? library_24.html

?? Glibc的中文手冊
?? HTML
?? 第 1 頁 / 共 4 頁
字號:
          exit (1);
        }
      else
        {
          /* This is the parent process.  */
          p->pid = pid;
          if (shell_is_interactive)
            {
              if (!j->pgid)
                j->pgid = pid;
              setpgid (pid, j->pgid);
            }
        }

      /* Clean up after pipes.  */
      if (infile != j->stdin)
        close (infile);
      if (outfile != j->stdout)
        close (outfile);
      infile = mypipe[0];
    }
  
  format_job_info (j, "launched");

  if (!shell_is_interactive)
    wait_for_job (j);
  else if (foreground)
    put_job_in_foreground (j, 0);
  else
    put_job_in_background (j, 0);
}
</PRE>
<P>
<H3><A NAME="SEC421" HREF="library_toc.html#SEC421" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC421">Foreground and Background</A></H3>
<P>
Now let's consider what actions must be taken by the shell when it
launches a job into the foreground, and how this differs from what
must be done when a background job is launched.
<A NAME="IDX1753"></A>
<P>
When a foreground job is launched, the shell must first give it access
to the controlling terminal by calling <CODE>tcsetpgrp</CODE>.  Then, the
shell should wait for processes in that process group to terminate or
stop.  This is discussed in more detail in 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>.
<P>
When all of the processes in the group have either completed or stopped,
the shell should regain control of the terminal for its own process
group by calling <CODE>tcsetpgrp</CODE> again.  Since stop signals caused by
I/O from a background process or a SUSP character typed by the user
are sent to the process group, normally all the processes in the job
stop together.
<P>
The foreground job may have left the terminal in a strange state, so the
shell should restore its own saved terminal modes before continuing.  In
case the job is merely been stopped, the shell should first save the
current terminal modes so that it can restore them later if the job is
continued.  The functions for dealing with terminal modes are
<CODE>tcgetattr</CODE> and <CODE>tcsetattr</CODE>; these are described in
section <A HREF="library_16.html#SEC272" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC272">Terminal Modes</A>.
<P>
Here is the sample shell's function for doing all of this.
<P>
<PRE>
/* Put job <VAR>j</VAR> in the foreground.  If <VAR>cont</VAR> is nonzero,
   restore the saved terminal modes and send the process group a
   <CODE>SIGCONT</CODE> signal to wake it up before we block.  */

void
put_job_in_foreground (job *j, int cont)
{
  /* Put the job into the foreground.  */
  tcsetpgrp (shell_terminal, j-&#62;pgid);

  /* Send the job a continue signal, if necessary.  */
  if (cont)
    {
      tcsetattr (shell_terminal, TCSADRAIN, &#38;j-&#62;tmodes);
      if (kill (- j-&#62;pgid, SIGCONT) &#60; 0)
        perror ("kill (SIGCONT)");
    }
  
  /* Wait for it to report.  */
  wait_for_job (j);
    
  /* Put the shell back in the foreground.  */
  tcsetpgrp (shell_terminal, shell_pgid);
    
  /* Restore the shell's terminal modes.  */
  tcgetattr (shell_terminal, &#38;j-&#62;tmodes);
  tcsetattr (shell_terminal, TCSADRAIN, &#38;shell_tmodes);
}
</PRE>
<A NAME="IDX1754"></A>
<P>
If the process group is launched as a background job, the shell should
remain in the foreground itself and continue to read commands from
the terminal.  
<P>
In the sample shell, there is not much that needs to be done to put
a job into the background.  Here is the function it uses:
<P>
<PRE>
/* Put a job in the background.  If the cont argument is true, send
   the process group a <CODE>SIGCONT</CODE> signal to wake it up.  */

void
put_job_in_background (job *j, int cont)
{
  /* Send the job a continue signal, if necessary.  */
  if (cont)
    if (kill (-j-&#62;pgid, SIGCONT) &#60; 0)
      perror ("kill (SIGCONT)");
}
</PRE>
<P>
<H3><A NAME="SEC422" HREF="library_toc.html#SEC422" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC422">Stopped and Terminated Jobs</A></H3>
<A NAME="IDX1755"></A>
<A NAME="IDX1756"></A>
<P>
When a foreground process is launched, the shell must block until all of
the processes in that job have either terminated or stopped.  It can do
this by calling the <CODE>waitpid</CODE> function; see section <A HREF="library_23.html#SEC407" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC407">Process Completion</A>.  Use the <CODE>WUNTRACED</CODE> option so that status is reported
for processes that stop as well as processes that terminate.
<P>
The shell must also check on the status of background jobs so that it
can report terminated and stopped jobs to the user; this can be done by
calling <CODE>waitpid</CODE> with the <CODE>WNOHANG</CODE> option.  A good place to
put a such a check for terminated and stopped jobs is just before
prompting for a new command.
<A NAME="IDX1757"></A>
<P>
The shell can also receive asynchronous notification that there is
status information available for a child process by establishing a
handler for <CODE>SIGCHLD</CODE> signals.  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>.
<P>
In the sample shell program, the <CODE>SIGCHLD</CODE> signal is normally
ignored.  This is to avoid reentrancy problems involving the global data
structures the shell manipulates.  But at specific times when the shell
is not using these data structures--such as when it is waiting for
input on the terminal--it makes sense to enable a handler for
<CODE>SIGCHLD</CODE>.  The same function that is used to do the synchronous
status checks (<CODE>do_job_notification</CODE>, in this case) can also be
called from within this handler.
<P>
Here are the parts of the sample shell program that deal with checking
the status of jobs and reporting the information to the user.
<P>
<PRE>
/* Store the status of the process <VAR>pid</VAR> that was returned by waitpid.
   Return 0 if all went well, nonzero otherwise.  */

int
mark_process_status (pid_t pid, int status)
{
  job *j;
  process *p;

  if (pid &#62; 0)
    {
      /* Update the record for the process.  */
      for (j = first_job; j; j = j-&#62;next)
        for (p = j-&#62;first_process; p; p = p-&#62;next)
          if (p-&#62;pid == pid)
            {
              p-&#62;status = status;
              if (WIFSTOPPED (status))
                p-&#62;stopped = 1;
              else
                {
                  p-&#62;completed = 1;
                  if (WIFSIGNALED (status))
                    fprintf (stderr, "%d: Terminated by signal %d.\n",
                             (int) pid, WTERMSIG (p-&#62;status));
                }
              return 0;
             }
      fprintf (stderr, "No child process %d.\n", pid);
      return -1;
    }
  else if (pid == 0 || errno == ECHILD)
    /* No processes ready to report.  */
    return -1;
  else {
    /* Other weird errors.  */
    perror ("waitpid");
    return -1;
  }
}

/* Check for processes that have status information available,
   without blocking.  */

void
update_status (void)
{
  int status;
  pid_t pid;
  
  do
    pid = waitpid (WAIT_ANY, &#38;status, WUNTRACED|WNOHANG);
  while (!mark_process_status (pid, status));
}

/* Check for processes that have status information available,
   blocking until all processes in the given job have reported.  */

void
wait_for_job (job *j)
{
  int status;
  pid_t pid;
  
  do
    pid = waitpid (WAIT_ANY, &#38;status, WUNTRACED);
  while (!mark_process_status (pid, status) 
         &#38;&#38; !job_is_stopped (j) 
         &#38;&#38; !job_is_completed (j));
}

/* Format information about job status for the user to look at.  */

void
format_job_info (job *j, const char *status)
{
  fprintf (stderr, "%ld (%s): %s\n", (long)j-&#62;pgid, status, j-&#62;command);
}

/* Notify the user about stopped or terminated jobs.
   Delete terminated jobs from the active job list.  */

void
do_job_notification (void)
{
  job *j, *jlast, *jnext;
  process *p;

  /* Update status information for child processes.  */
  update_status ();
  
  jlast = NULL;
  for (j = first_job; j; j = jnext)
    {
      jnext = j-&#62;next;

      /* If all processes have completed, tell the user the job has
         completed and delete it from the list of active jobs.  */
      if (job_is_completed (j)) {
        format_job_info (j, "completed");
        if (jlast)
          jlast-&#62;next = jnext;
        else
          first_job = jnext;
        free_job (j);
      }

      /* Notify the user about stopped jobs,
         marking them so that we won't do this more than once.  */
      else if (job_is_stopped (j) &#38;&#38; !j-&#62;notified) {
        format_job_info (j, "stopped");
        j-&#62;notified = 1;
        jlast = j;
      }

      /* Don't say anything about jobs that are still running.  */
      else
        jlast = j;
    }
}
</PRE>
<P>
<H3><A NAME="SEC423" HREF="library_toc.html#SEC423" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC423">Continuing Stopped Jobs</A></H3>
<A NAME="IDX1758"></A>
<P>
The shell can continue a stopped job by sending a <CODE>SIGCONT</CODE> signal
to its process group.  If the job is being continued in the foreground,
the shell should first invoke <CODE>tcsetpgrp</CODE> to give the job access to
the terminal, and restore the saved terminal settings.  After continuing
a job in the foreground, the shell should wait for the job to stop or
complete, as if the job had just been launched in the foreground.
<P>
The sample shell program uses the same set of
functions---<CODE>put_job_in_foreground</CODE> and
<CODE>put_job_in_background</CODE>---to handle both newly created and

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成a人v欧美综合天堂| 久久伊99综合婷婷久久伊| 欧美日韩大陆在线| 久久久久久久久久久久电影| 亚洲免费观看高清| 国产一区二区免费视频| 91精品中文字幕一区二区三区| www国产精品av| 久久国产精品99精品国产| 蜜臀精品久久久久久蜜臀| 欧美亚一区二区| 精品福利一二区| 亚洲欧美成aⅴ人在线观看| 久久成人免费网| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 国产精品伊人色| 国产精品高潮久久久久无| 日韩欧美亚洲国产精品字幕久久久 | 毛片不卡一区二区| 亚洲影院理伦片| 国产精品污污网站在线观看| 久久99国产精品久久99果冻传媒| 欧美日韩aaaaa| 亚洲国产精品久久不卡毛片 | 777久久久精品| 亚洲国产精品影院| 欧美日韩在线免费视频| 日韩高清不卡在线| 欧美一级片在线看| 国产美女精品人人做人人爽| 26uuu精品一区二区三区四区在线| 日韩av中文字幕一区二区| 日韩一区二区中文字幕| 大白屁股一区二区视频| 污片在线观看一区二区| 欧美性受极品xxxx喷水| 亚洲国产精品影院| 在线免费不卡视频| 亚洲天堂网中文字| 欧美日本一区二区在线观看| 99久久精品99国产精品| youjizz国产精品| 国产色综合一区| 久久久久9999亚洲精品| 日韩欧美国产一区二区三区| 国产999精品久久| 狠狠色综合日日| 黄一区二区三区| 国产在线视视频有精品| 免费看精品久久片| 国产精品久久久久久妇女6080 | 亚洲精品伦理在线| 亚洲乱码国产乱码精品精98午夜| 韩国成人在线视频| 亚洲精品水蜜桃| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 国产精品久久久久久久蜜臀| 精品国产凹凸成av人导航| 91精品国模一区二区三区| 欧美白人最猛性xxxxx69交| 67194成人在线观看| 日韩欧美一卡二卡| 欧美成人三级电影在线| 精品成人佐山爱一区二区| 久久综合九色综合欧美亚洲| 精品久久国产字幕高潮| 国产片一区二区| 亚洲欧洲精品天堂一级 | 国产精品亚洲第一| av成人免费在线| 色天天综合久久久久综合片| 成人午夜看片网址| 欧美在线一区二区三区| 欧美日韩国产首页在线观看| xfplay精品久久| 欧美激情一区二区三区不卡| 亚洲综合视频网| 日本在线观看不卡视频| 夜夜爽夜夜爽精品视频| 日本视频在线一区| 国产美女在线精品| 一本一道久久a久久精品| 欧美午夜精品免费| 亚洲精品在线一区二区| 日韩美女视频一区二区| 热久久一区二区| 国产风韵犹存在线视精品| 97久久精品人人爽人人爽蜜臀| 欧美午夜不卡视频| 欧美日韩黄色一区二区| 欧美大白屁股肥臀xxxxxx| 国产精品人人做人人爽人人添| 亚洲影视在线观看| 久久国产生活片100| 91国偷自产一区二区开放时间 | 一本色道久久综合精品竹菊| 91精品国产乱码久久蜜臀| 久久久久综合网| 日本欧美在线观看| 成人精品国产福利| 精品国产91乱码一区二区三区| 日韩一区在线免费观看| 亚洲国产欧美在线| 亚洲人成电影网站色mp4| 午夜精品成人在线| 成人丝袜18视频在线观看| 制服视频三区第一页精品| 国产农村妇女毛片精品久久麻豆 | 中文字幕av资源一区| 亚洲一区二区黄色| 国产精品资源网站| 日韩片之四级片| 亚洲一二三四区不卡| www.av精品| 国产精品久久久久久亚洲毛片| 日本vs亚洲vs韩国一区三区二区| 69堂精品视频| 一区二区三区在线免费| 欧美伦理影视网| 日韩欧美中文字幕精品| 亚洲天天做日日做天天谢日日欢| 日韩黄色免费电影| 欧美日韩国产精选| 国产美女精品一区二区三区| 蜜乳av一区二区| 亚洲午夜久久久久中文字幕久| 日韩美女视频19| 国产乱码精品一区二区三区五月婷| 91精品欧美一区二区三区综合在| 国产精品国产馆在线真实露脸| 国产69精品久久久久777| 欧美www视频| 樱桃视频在线观看一区| 91丝袜高跟美女视频| 国产色91在线| 国产成人在线色| 欧美大片一区二区三区| 麻豆精品一区二区| 91精品啪在线观看国产60岁| 免费在线看成人av| 欧美日韩免费不卡视频一区二区三区| 国产精品久久久久久久第一福利| 欧美精品在线一区二区| 视频一区在线视频| 久久久精品国产99久久精品芒果 | 视频一区二区中文字幕| 欧美一区二区视频在线观看| 蜜臀91精品一区二区三区| 欧美一区二区观看视频| 爽好多水快深点欧美视频| 欧美综合一区二区三区| 看电视剧不卡顿的网站| 日本一区二区免费在线| 国产69精品久久久久毛片| 亚洲制服丝袜一区| 日韩一区二区三区免费观看| 欧美日韩国产电影| 91在线观看免费视频| 在线视频一区二区三区| 色成人在线视频| 蜜桃av噜噜一区二区三区小说| 欧美体内she精高潮| 激情小说欧美图片| 亚洲最新视频在线观看| 亚洲欧美综合另类在线卡通| 不卡一区二区三区四区| 欧美怡红院视频| 久久精品一区二区| 从欧美一区二区三区| 亚洲国产日韩一级| 欧美剧情电影在线观看完整版免费励志电影| 日日夜夜精品免费视频| 日韩一区二区三区四区| 亚洲免费在线观看视频| 日韩午夜激情电影| 国产99久久精品| 亚洲成人免费在线观看| 这里只有精品视频在线观看| 国产成人精品综合在线观看 | 精品播放一区二区| 成人h版在线观看| 天天色综合天天| 久久久久久久久岛国免费| 美女www一区二区| 综合中文字幕亚洲| 91精品国产手机| 成人三级伦理片| 亚洲无线码一区二区三区| 国产欧美日韩精品a在线观看| 波多野结衣一区二区三区| 午夜激情综合网| 欧美国产精品劲爆| 91浏览器入口在线观看| 国产精品69毛片高清亚洲| 亚洲乱码一区二区三区在线观看| 欧美一级爆毛片| 91在线国产福利| 国产99精品国产| 日韩不卡一区二区三区| 亚洲人成网站在线|