Re: pg_ctl start broken on windows
От | Gary Doades |
---|---|
Тема | Re: pg_ctl start broken on windows |
Дата | |
Msg-id | 40C77D68.7337.13AAF9@localhost обсуждение исходный текст |
Ответ на | Re: pg_ctl start broken on windows (Andrew Dunstan <andrew@dunslane.net>) |
Ответы |
Re: pg_ctl start broken on windows
|
Список | pgsql-hackers-win32 |
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. Regards, Gary.
В списке pgsql-hackers-win32 по дате отправления: