This is the mail archive of the cygwin@sources.redhat.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: (detached) background (console) processes


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]