Re: pg_ctl start broken on windows

"Gary Doades" <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32
Message-ID <40C8E23A.4842.164797@localhost>
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.

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.