Gary Doades wrote:
>On 9 Jun 2004 at 15:43, Andrew Dunstan wrote:
>>I don't see that it buys you much. But maybe you'd like to submit a
>>patch? (What is there isn't a desktop window, e.g. we are starting from
>>the service manager, as has been suggested for pg_ctl?)
>It doesn't buy you anything except a few lines of code. I thought you
>were looking for simplicity. I suggested this as a simple drop in
>replacement for the system() call. I could do a patch, but by the time I
>figured out where to put it etc, someone who knows the code well could
>just drop this in.
>Is it pg_ctl that is a service and this starts postmaster? If so then I
>agree that you will probably need CreateProcess. This will give you
>much more control over the created process anyway.
>Here is a minimal example for CreateProcess
> STARTUPINFO si;
> PROCESS_INFORMATION pi;
> ZeroMemory( &si, sizeof(si) );
> si.cb = sizeof(si);
> ZeroMemory( &pi, sizeof(pi) );
> // Start the child process.
> if( !CreateProcess( "c:\\windows\system32\cmd.exe", // executable
> "arg1 arg2 arg3", // Command line.
> NULL, // Process handle not inheritable.
> NULL, // Thread handle not inheritable.
> FALSE, // Set handle inheritance to FALSE.
> 0, // No creation flags.
> NULL, // Use parent's environment block.
> NULL, // Use parent's starting directory.
> &si, // Pointer to STARTUPINFO structure.
> &pi ) // Pointer to PROCESS_INFORMATION structure.
> ErrorExit( "CreateProcess failed." );
> // Close process and thread handles.
> CloseHandle( pi.hProcess );
> CloseHandle( pi.hThread );
>where ZeroMemory is whatever convenient function you have for
>clearing a block of memory.
>You MUST close the process and thread handles afterwards to avoid
>handle leaks. You could of course use (not close) the process handle in
>pg_ctl (if it was the permanently running service) to monitor postmaster
>for crashing out.
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.
In response to
pgsql-hackers-win32 by date
|Next:||From: Bruce Momjian||Date: 2004-06-10 16:34:38|
|Subject: Re: pg_ctl start broken on windows|
|Previous:||From: Bruce Momjian||Date: 2004-06-10 04:01:25|
|Subject: Re: [HACKERS] select like...not using index|