[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: glut/freeglut and fork()

On Mon, Feb 16, 2004 at 02:54:31PM +0100, Francesco Orsenigo wrote:
> Steve Baker:
> >  It seems to me that a more natural approach would be to have the server be
> >  the main program, have it immediately start a client, then the client can
> >  decide either to connect to the local server that started it - or to some
> >  remote server off on the network.
> [cut]
> Of course it is, but while client is always started, server must be started 
> only when hosting a game....

Erm... Why?

It'll just get swapped out (in fact the binary pages will never get
loaded) and then ignored. All it needs to do is run a forever select
on the pipe connecting it to the client that the client uses to wake
it up when it actually is needed.

> The cleaner solution would be to fork() before any initialization is done, and 
> then keeping the server idle,

Yeah. See...

> or even use this idle thread just to fork() a 
> server thread, or even exec() it.
> Maybe fork()ing twice is the best solution.
> Again, lot of testing awaits me....

Or reading the manual. Forking twice is what you do for a daemon that
will never exit.