HI,
In our project, we have unix socket networking going on and the Postgresql 
code is the server in this process. We would want the postgresql database to 
run as usual while it is transferring data (as a server) to another program 
(the client, in our case, a GUI). Therefore, we would want to fork another 
process that acts as the server.
Would anyone kindly suggest where would be the best place for us to call 
fork() in this case?
Would this src/backend/main/main.c be a good place to put the fork() and 
server code?
If yes, in which part in particular, or does it matter?
If not, in which file would it be better to put it?
Thank you,
Sumaira





_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail


Thu, 24 Apr 2003 00:46:38 -0700
"S -" <nat_lazy@hotmail.com>
forking child processes in src/backend/main/main.c
>>>>> "S" == nat lazy <S> writes:

    S> Would anyone kindly suggest where would be the best place for
    S> us to call fork() in this case?

    S> Would this src/backend/main/main.c be a good place to put the
    S> fork() and server code?

In the TelegraphCQ project we have started with the postgres code base
and done something like what you are trying. More specifically, long
running continuous queries are run in a separate process (as is the
code that is responsible for streaming in data from external sources). 

The way we do it is to pass an extra argument to BackendStartup()
(which is called from serverloop() called from PostmasterMain()) - the
extra argument suggests whether or not the backend being started up is
a regular postgres process (that we call the TelegraphCQ Front-End) or
if its the query-processing backend (the TCQ BE) or the TCQ Wrapper
ClearingHouse. We make our separate calls to BackendStartup() right
before the serverloop in PostmasterMain() .. within BackendStartup we
run the appropriate code based on the extra argument passed.

You can look at a very-very alpha version of our code in
http://telegraph.cs.berkeley.edu/telegraphcq

TCQ 0.1 is based on pgsql-7.2.1 - however most of what I've said
should work on the new code base (we're currently merging upto 7.3.2). 

-- 
Pip-pip
Sailesh
http://www.cs.berkeley.edu/~sailesh


24 Apr 2003 01:20:51 -0700
Sailesh Krishnamurthy <sailesh@cs.berkeley.edu>
Re: forking child processes in src/backend/main/main.c
"S -" <nat_lazy@hotmail.com> writes:
> In our project, we have unix socket networking going on and the Postgresql 
> code is the server in this process. We would want the postgresql database to 
> run as usual while it is transferring data (as a server) to another program 
> (the client, in our case, a GUI). Therefore, we would want to fork another 
> process that acts as the server.

What exactly is this doing that's different from having two separate
database connections served by two backend processes?

			regards, tom lane


Thu, 24 Apr 2003 09:03:57 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: forking child processes in src/backend/main/main.c 