Re: BUG #10330: pg_ctl does not correctly honor "DETACHED_PROCESS" - Mailing list pgsql-bugs

From Thomas Hruska
Subject Re: BUG #10330: pg_ctl does not correctly honor "DETACHED_PROCESS"
Date
Msg-id 53759733.3040204@cubiclesoft.com
Whole thread Raw
In response to Re: BUG #10330: pg_ctl does not correctly honor "DETACHED_PROCESS"  (Thomas Hruska <thruska@cubiclesoft.com>)
Responses Re: BUG #10330: pg_ctl does not correctly honor "DETACHED_PROCESS"  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
On 5/15/2014 9:26 PM, Thomas Hruska wrote:
> Somewhere around line 4227 is this code:
>
>      if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE,
> CREATE_SUSPENDED, NULL, NULL, &si, &pi))
>
>
> Adding DETACHED_PROCESS should fix the problem of the OS spawning a
> bunch of console windows when 'postgres.exe' is called directly without
> an attached console:
>
>
>      if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE,
> CREATE_SUSPENDED | DETACHED_PROCESS, NULL, NULL, &si, &pi))

Minor correction.  Detect the lack of a console, THEN add DETACHED_PROCESS:

    if (!CreateProcess(NULL, cmdLine, NULL, NULL, TRUE, CREATE_SUSPENDED |
(GetConsoleWindow() == NULL ? DETACHED_PROCESS : 0), NULL, NULL, &si, &pi))

That should allow standard input/output handles to function as expected
when there is a console.

--
Thomas Hruska
CubicleSoft President

I've got great, time saving software that you will find useful.

http://cubiclesoft.com/

pgsql-bugs by date:

Previous
From: Thomas Hruska
Date:
Subject: Re: BUG #10330: pg_ctl does not correctly honor "DETACHED_PROCESS"
Next
From: Greg Stark
Date:
Subject: Re: BUG #10329: Could not read block 0 in file "base/56100265/57047884": read only 0 of 8192 bytes