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