(libc.info.gz) Continuing Stopped Jobs

Info Catalog (libc.info.gz) Stopped and Terminated Jobs (libc.info.gz) Implementing a Shell (libc.info.gz) Missing Pieces
 
 27.6.6 Continuing Stopped Jobs
 ------------------------------
 
 The shell can continue a stopped job by sending a `SIGCONT' signal to
 its process group.  If the job is being continued in the foreground,
 the shell should first invoke `tcsetpgrp' 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.
 
    The sample shell program handles both newly created and continued
 jobs with the same pair of functions, `put_job_in_foreground' and
 `put_job_in_background'.  The definitions of these functions were given
 in  Foreground and Background.  When continuing a stopped job, a
 nonzero value is passed as the CONT argument to ensure that the
 `SIGCONT' signal is sent and the terminal modes reset, as appropriate.
 
    This leaves only a function for updating the shell's internal
 bookkeeping about the job being continued:
 
      /* Mark a stopped job J as being running again.  */
 
      void
      mark_job_as_running (job *j)
      {
        Process *p;
 
        for (p = j->first_process; p; p = p->next)
          p->stopped = 0;
        j->notified = 0;
      }
 
      /* Continue the job J.  */
 
      void
      continue_job (job *j, int foreground)
      {
        mark_job_as_running (j);
        if (foreground)
          put_job_in_foreground (j, 1);
        else
          put_job_in_background (j, 1);
      }
 
Info Catalog (libc.info.gz) Stopped and Terminated Jobs (libc.info.gz) Implementing a Shell (libc.info.gz) Missing Pieces
automatically generated by info2html