home *** CD-ROM | disk | FTP | other *** search
- 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+
- From: fl0p+@andrew.cmu.edu (Frank T Lofaro)
- Newsgroups: comp.unix.internals
- Subject: Re: How can a Unix process put itself in background?
- Message-ID: <ceggQDG00VozICsUcq@andrew.cmu.edu>
- Date: 12 Sep 92 20:43:59 GMT
- Article-I.D.: andrew.ceggQDG00VozICsUcq
- References: <1992Sep11.170405.28836@tandem.com> <18qopsINN12n@early-bird.think.com> <1992Sep11.222546.3878@tandem.com>
- <18rlr4INNi23@early-bird.think.com>
- Organization: Sophomore, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA
- Lines: 19
- In-Reply-To: <18rlr4INNi23@early-bird.think.com>
-
- This is a real obscene way of getting it to work, and it very well might
- not work. However, you should give it a try:
-
- Have the process fork. (don't worry, the parent is what lives on in the
- end, not the child, so this should be okay for you.)
- The parent does a kill(getpid(),SIGSTOP).
- The child does a sleep(1);kill(getppid,SIGCONT), and then exit
- after the parent resumes, have it mess with the tty so that it is in the
- background as far as tty interaction goes (e.g. setsid()).
-
- Note: sleep(1) should be enough, but it might not be.
- Also, this is a real kludgy way of doing it, but it has a good chance of
- working.
-
- The process getting itself stopped should cause the wait4 in the shell
- to return. The fork and sigcont are needed so that the process doesn't
- sleep forever.
-
- I hope this helps.
-