home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / internal / 1576 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  3.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!think.com!barmar
  2. From: barmar@think.com (Barry Margolin)
  3. Newsgroups: comp.unix.internals
  4. Subject: Re: Background processes and stdin
  5. Date: 21 Jul 1992 22:48:45 GMT
  6. Organization: Thinking Machines Corporation, Cambridge MA, USA
  7. Lines: 63
  8. Distribution: na
  9. Message-ID: <14i48dINNnio@early-bird.think.com>
  10. References: <1992Jul21.023713.2702@hubcap.clemson.edu>
  11. NNTP-Posting-Host: telecaster.think.com
  12.  
  13. In article <1992Jul21.023713.2702@hubcap.clemson.edu> rsaripa@saturn.cs.clemson.edu (Saripalli Ramakrishna) writes:
  14. >    When a background process needs terminal input,it is stopped.
  15. >    The message "Stopped " appears on the output.
  16. >
  17. >    Now,I would like to know why this happens.I think the signal
  18. >    SIGTTIN is sent to the process but why it is sent?.
  19.  
  20. Here are excerpts from the SunOS termio(4) man page that answer this.
  21.  
  22.   Process Groups
  23.      A terminal may have a distinguished process group associated
  24.      with  it.   This distinguished process group plays a special
  25.      role in handling signal-generating input characters, as dis-
  26.      cussed  below  in the Special Characters section below.  The
  27.      terminal's process group can can  be  set  only  to  process
  28.      groups that are members of the terminal's session.
  29.  
  30.      A command interpreter, such as csh(1),  that  supports  "job
  31.      control"  can  allocate  the  terminal to different jobs, or
  32.      process groups, by placing related  processes  in  a  single
  33.      process  group  and  associating this process group with the
  34.      terminal.  A terminal's associated process group may be  set
  35.      or  examined  by  a process with sufficient privileges.  The
  36.      terminal interface aids in this  allocation  by  restricting
  37.      access  to  the  terminal  by  processes that are not in the
  38.      current process group; see Job Access Control below.
  39. ...
  40.   Job Access Control
  41.      If a process is  in  the  (non-zero)  distinguished  process
  42.      group of its controlling terminal (if this is true, the pro-
  43.      cess is said to be  a  foreground  process),  then  read(2V)
  44.      operations  are allowed as described below in Input Process-
  45.      ing and Reading Characters.  If a  process  is  not  in  the
  46.      (non-zero)  distinguished  process  group of its controlling
  47.      terminal (if this is true, the process is said to be a back-
  48.      ground  process), then any attempts to read from that termi-
  49.      nal will  typically  send  that  process'  process  group  a
  50.      SIGTTIN  signal.   If  the  process is ignoring SIGTTIN, has
  51.      SIGTTIN blocked, is a member of an orphaned  process  group,
  52.      or  is in the middle of process creation using vfork(2), the
  53.      read will return -1 and set errno to EIO,  and  the  SIGTTIN
  54.      signal  will  not be sent.  The SIGTTIN signal will normally
  55.      stop the members of that process group.
  56.  
  57.      When the TOSTOP bit is set in the c_lflag field, attempts by
  58.      a  background  process  to write to its controlling terminal
  59.      will typically send that process' process  group  a  SIGTTOU
  60.      signal.   If  the  process  is ignoring SIGTTOU, has SIGTTOU
  61.      blocked, or is in  the  middle  of  process  creation  using
  62.      vfork(),  the process will be allowed to write to the termi-
  63.      nal and the SIGTTOU signal will not be sent. If the  process
  64.      is  orphaned, the write will return -1 and set errno to EIO,
  65.      and the SIGTTOU signal will not be sent. SIGTTOU signal will
  66.      normally  stop  the  members of that process group.  Certain
  67.      ioctl() calls that set terminal parameters  are  treated  in
  68.      this  same  fashion,  except that TOSTOP is not checked; the
  69.      effect is identical to that of terminal writes  when  TOSTOP
  70.      is set.  See IOCTLS.
  71. -- 
  72. Barry Margolin
  73. System Manager, Thinking Machines Corp.
  74.  
  75. barmar@think.com          {uunet,harvard}!think!barmar
  76.