Creating background application

Hi,
I am developing a driver that I want to run in the foreground on
startup, but then go into the background once it’s gone into it’s main
loop. I have seen this done before with many programs in QNX (automap,
Net.ether1000, Fsys.eide, etc…) but I’m sure quite how it’s done.
Can someone give me a push in the right direction as to where I would
learn how to accomplish such a thing.
Thanks in advance,


Chris Nasr
cnasr[at]mechtronix[dot]ca
R&D Programming
Mechtronix Systems Inc.

I had a thought.

I created a secondary thread for my main loop (using _beginthread), then
simply continued and exited the main thread, this gave me the behaviour I
was looking for.
However, is this the correct way to do it, or is there some better way?

Thanks,


Chris Nasr
cnasr[at]mechtronix[dot]ca
R&D Programming
Mechtronix Systems Inc.

Chris Nasr <cnasr@mechtronix.ca> wrote:

Hi,
I am developing a driver that I want to run in the foreground on
startup, but then go into the background once it’s gone into it’s main
loop. I have seen this done before with many programs in QNX (automap,
Net.ether1000, Fsys.eide, etc…) but I’m sure quite how it’s done.
Can someone give me a push in the right direction as to where I would
learn how to accomplish such a thing.
Thanks in advance,

The accepted procedure looks like this:
(Note: This is from QNX4, but it should be similar.)

// load in background
int n = fork();
if( n == -1 )
{
// error
}
if( n != 0 )
return ok; // this is the parent - only child remains
setsid(); // become a session leader


Bill Caroselli – Q-TPS Consulting
1-(626) 824-7983
qtps@earthlink.net

http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Progr
amming/Q_20324922.html

“Chris Nasr” <cnasr@mechtronix.ca> wrote in message
news:3E36F039.DDA2E6CE@mechtronix.ca

I had a thought.

I created a secondary thread for my main loop (using _beginthread), then
simply continued and exited the main thread, this gave me the behaviour I
was looking for.
However, is this the correct way to do it, or is there some better way?

Thanks,


Chris Nasr
cnasr[at]mechtronix[dot]ca
R&D Programming
Mechtronix Systems Inc.

Thanks Bill and Richard
I forked then closed the parent and it worked like a charm.


Chris Nasr
cnasr[at]mechtronix[dot]ca
R&D Programming
Mechtronix Systems Inc.