delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/01/16/12:06:27

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs
Date: Tue, 16 Jan 2001 11:02:58 -0600 (CST)
From: Mumit Khan <khan AT NanoTech DOT Wisc DOT EDU>
To: Kaatunut <kaatunut AT iki DOT fi>
cc: cygwin AT cygwin DOT com
Subject: Re: (detached) background (console) processes
In-Reply-To: <4.3.1.2.20010115113218.0231b4b0@pop.ma.ultranet.com>
Message-ID: <Pine.HPP.3.96.1010116110036.7454E-100000@hp2.xraylith.wisc.edu>
MIME-Version: 1.0

On Mon, 15 Jan 2001, Larry Hall (RFK Partners, Inc) wrote:

> At 10:18 AM 1/15/2001, Kaatunut wrote:
> >How do I create a console (well, actually, console-less) process that I
> >can leave running at background- that is, no need for terminal? Under
> >unix, I would just do
> >
> >if (fork()) { exit(0); }
> >// I'm in background now
> >
> >but as I compile that on not-so-old gcc 2.95.2 on win32 (cygwin default
> >compiler or whatever, not mingw32) and run it, the terminal won't detach
> >and let me quit. And if I kill it, the child dies also.
> >
> >I tried searching archives but found nothing useful; however, from one
> >post over two years old I got the impression I should have to
> >detach something. How does this happen?
> >
> >  -Kaatunut
> 
> 
> 
> Take a look at the documentation for CreateProcess() in the MSDN and the
> code in winsup/cygwin/fork.cc.  You should be able to figure out something
> to do what you want from this.
> 

Note that there is more to making a program run in the background
correctly than just using fork, and that applies to all Unix-like
systems. You'll need to do deal session leaders and controlling ttys
and so on (different flavors such as SysV4 and BSD do things a bit
differently, and POSIX uses a combination of the two approaches).

I suggest you pick up a copy of (late) W. Richard Stevens' book on
Advanced Unix Programming that provides all that you need to do.

Regards,
Mumit



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019