Re: win2k, service, pg_ctl, popen, etc - Mailing list pgsql-hackers-win32

From Bruce Momjian
Subject Re: win2k, service, pg_ctl, popen, etc
Date
Msg-id 200407202059.i6KKxWm24835@candle.pha.pa.us
Whole thread Raw
In response to win2k, service, pg_ctl, popen, etc  ("Magnus Hagander" <mha@sollentuna.net>)
List pgsql-hackers-win32
Magnus Hagander wrote:
> Hi!
>
> Been trying to find out why things don't work well on Windows 2000. The
> closest I've come to a solution is that popen() does not work on windows
> 2000 *when running as a service*. This isused in find_other_exec(),
> which is what pg_ctl uses to find postmaster.exe. It does appear to work
> fine on XP and 2003. Haven't tested NT4.
> The symptoms are popen() returning NULL, with both errno and
> GetLastError() set to 0.
>
> Anyone know *why* this doesn't work?
>
> If we don't know why, sign one more down as a bug in mingw (hardly
> surprising - just the area of pipes and consoles seems to be where it's
> weak). In that case, why not just recode pg_ctl to execute
> postmaster.exe from the same directory it found pg_ctl.exe in. This can
> easily be done using GetModuleFileName(). Is a pipe opened at any other
> place? Or does other places need to be fixed as well (I haven't gone
> through the whole code).
>
> Oh, and also - has *anybody* got the service running wit hpg_ctl as
> service wrapper on windows 2000? In that case, it's version or
> environment dependent...

Via IM, Magnus told me the cause is that there is no stdin/stdout/stderr
when running as a service:


http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&threadm=3475F130.80F%40us.ibm.com&rnum=1&prev=/groups%3Fq%3Dwin32%2Bpopen%2Bservice%26hl%3Den%26lr%3D%26ie%3DUTF-8%26safe%3Doff%26selm%3D3475F130.80F%2540us.ibm.com%26rnum%3D1

http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&safe=off&threadm=5f4arb%24q5n%40chaos.dac.neu.edu&rnum=7&prev=/groups%3Fq%3Dwin32%2Bpopen%2Bservice%26hl%3Den%26lr%3D%26ie%3DUTF-8%26safe%3Doff%26selm%3D5f4arb%2524q5n%2540chaos.dac.neu.edu%26rnum%3D7

The only solution I can think of is to do:

    system("cmd > %tmpdir%/pgsql_###.tmp")

and then read 'pgsql_###.tmp'.  ### would be the port number.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-hackers-win32 by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: win2k, service, pg_ctl, popen, etc
Next
From: Steve Holdoway
Date:
Subject: Borland c++ compile problems...