Re: pg_ctl start broken on windows

From: "Gary Doades" <gpd(at)gpdnet(dot)co(dot)uk>
To: pgsql-hackers-win32 <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: pg_ctl start broken on windows
Date: 2004-06-10 21:35:38
Message-ID: 40C8E23A.4842.164797@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32

On 10 Jun 2004 at 10:45, Andrew Dunstan wrote:
>
> Thanks. The file to patch is src/bin/pg_ctl/pg_ctl.c
>
> We'll need to do a bit more work than this, though. We have 2 cases -
> one where there's a logfile parameter and one where there isn't. Both
> cases need stdin to be the null device (is that the default if you say
> no handle inheritance?). If there is no logfile parameter then the
> process's stdout and stderr handles need to be those of the calling
> process (i.e. pg_ctl). If there is such a param then the postmaster's
> stdout and stderr both need to be a handle on that file, opened in
> append mode. I believe this needs to be set up in the STARTUPINFO
> (reading MSDN makes my brain hurt).
>
> Not sure of any other wrinkles.
>
> cheers
>
> andrew

Hmm, I have managed to look at the pg_ctl.c code and I can't find any code in there for
the service manager. If pg_ctl is to be run as a true service then there is a *lot* more
work to do on this.

I have used CreateProcess many times, but not redirecting the standard filestreams, I
would have to think about that and do some experimentation. I thought that it might just
be a case of dropping the CreateProcess code in and I could have done that with no
probs.

I believe at first glance that what you want can be done, but I don't think it is trivial.
MSDN can be a real brain killer. Try taking a look at the service code. This is the code
that would need to be put into pg_ctl to respond to the service manager
(SERVICE_CONTROL_STOP, SERVICE_CONTROL_INTERROGATE,
SERVICE_CONTROL_SHUTDOWN at a minimum) This also inherently would make
pg_ctl multi threaded.

Unfortunately I just don't have the few days that I would expect it to take to knock this
into proper shape for a service with full redirection of the filestreams. I don't currently
have anything set up for compiling postgres on my PC. I might be able to have a go at
something next week or I could throw things around with another Windows person.

Regards,
Gary.

In response to

Responses

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Andrew Dunstan 2004-06-10 21:41:07 Re: pg_ctl start broken on windows
Previous Message Bruce Momjian 2004-06-10 16:34:38 Re: pg_ctl start broken on windows