home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / internal / 1802 < prev    next >
Encoding:
Internet Message Format  |  1992-09-12  |  1.5 KB

  1. Path: sparky!uunet!usc!zaphod.mps.ohio-state.edu!rpi!usenet.coe.montana.edu!news.u.washington.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!fl0p+
  2. From: fl0p+@andrew.cmu.edu (Frank T Lofaro)
  3. Newsgroups: comp.unix.internals
  4. Subject: Re: How can a Unix process put itself in background?
  5. Message-ID: <ceggQDG00VozICsUcq@andrew.cmu.edu>
  6. Date: 12 Sep 92 20:43:59 GMT
  7. Article-I.D.: andrew.ceggQDG00VozICsUcq
  8. References: <1992Sep11.170405.28836@tandem.com> <18qopsINN12n@early-bird.think.com> <1992Sep11.222546.3878@tandem.com>
  9.     <18rlr4INNi23@early-bird.think.com>
  10. Organization: Sophomore, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
  11. Lines: 19
  12. In-Reply-To: <18rlr4INNi23@early-bird.think.com>
  13.  
  14. This is a real obscene way of getting it to work, and it very well might
  15. not work. However, you should give it a try:
  16.  
  17. Have the process fork. (don't worry, the parent is what lives on in the
  18. end, not the child, so this should be okay for you.)
  19. The parent does a kill(getpid(),SIGSTOP).
  20. The child does a sleep(1);kill(getppid,SIGCONT), and then exit
  21. after the parent resumes, have it mess with the tty so that it is in the
  22. background as far as tty interaction goes (e.g. setsid()).
  23.  
  24. Note: sleep(1) should be enough, but it might not be.
  25. Also, this is a real kludgy way of doing it, but it has a good chance of
  26. working.
  27.  
  28. The process getting itself stopped should cause the wait4 in the shell
  29. to return. The fork and sigcont are needed so that the process doesn't
  30. sleep forever.
  31.  
  32. I hope this helps.
  33.