home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / internal / 1796 < prev    next >
Encoding:
Text File  |  1992-09-11  |  2.3 KB  |  50 lines

  1. Newsgroups: comp.unix.internals
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsc!cbfsb!att-out!pacbell.com!tandem!hood!bill
  3. From: norcott_bill@tandem.com (Bill Norcott)
  4. Subject: Re: How can a Unix process put itself in background?
  5. Message-ID: <1992Sep11.170405.28836@tandem.com>
  6. Sender: news@tandem.com
  7. Nntp-Posting-Host: hood.tsg.tandem.com
  8. Reply-To: norcott_bill@tandem.com  (Bill Norcott)
  9. Organization: Tandem Computers, Inc.
  10. References:  <lma.716056953@dayton.Stanford.EDU>
  11. Date: Fri, 11 Sep 1992 17:04:05 GMT
  12. Lines: 36
  13.  
  14. In article <lma.716056953@dayton.Stanford.EDU>, lma@dayton.Stanford.EDU (Larry Augustin) writes:
  15. |> Someone stopped by my office with this question yesterday.
  16. |> 
  17. |> A user invokes a program at the shell, and interacts with the program
  18. |> for a short time.  Eventually the user selects some "quit" option of
  19. |> the program.  Before the program really quits, it wants to go off and
  20. |> spend a minute or two checking some database files on disk.  Is there
  21. |> any way for the program to return control to the user's shell while it
  22. |> does the background stuff?  In effect, the program wants to "detach"
  23. |> itself from stdin/stdout, return control to the shell, and continue in
  24. |> background for a while before exiting.
  25. |> 
  26. |> The only solutions we could come up with were based on forking a child
  27. |> to do the background part.  is this the only way to do it?  Is there a
  28. |> solution that does not need a fork?
  29. |> 
  30.  
  31. If you have a POSIX 1003.1 conforming system, a process can put 
  32. itself into the background with the setpgid() system call.  This
  33. is "set process group".  A process can put itself into the background
  34. by joining a background process group.  A process can find out its
  35. own process group by calling getpgrp().  A process can disconnect
  36. itself from the controlling terminal and create its own session
  37. (and become a session- and group-leader).  This will push the process
  38. into the background.  These are the mechanisms a shell uses to
  39. implement job control.  Take a look at the man pages for these 
  40. functions, I'm sure you can get it to work.
  41.  
  42. -- 
  43. ---------------------------------------------------------------------|
  44. Bill Norcott            GUARDIAN POSIX project
  45. Tandem Computers, Inc.        
  46. 10600 N. Tantau Avenue        PHONE:  (408) 285-3253
  47. Cupertino, CA   95014        EMAIL: norcott_bill@tandem.com
  48.  
  49.  
  50.