Skip site navigation (1) Skip section navigation (2)

Re: [ANNOUNCEMENT] Updated: cygrunsrv-0.94-1

From: Fred Yankowski <fred(at)ontosys(dot)com>
To: cygwin(at)cygwin(dot)com, pgsql-cygwin(at)postgresql(dot)org
Subject: Re: [ANNOUNCEMENT] Updated: cygrunsrv-0.94-1
Date: 2001-07-16 16:51:00
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-cygwin
On Mon, Jul 16, 2001 at 06:27:27PM +0200, Corinna Vinschen wrote:
> For example when changing the runlevel on a Linux system is requested,
> init(8) sends a SIGTERM to processes which aren't defined on the new
> runlevel. Which is a similar situation, IMO. Perhaps changing Cygwin
> from sending SIGHUP to sending SIGTERM makes any sense?

Sending SIGTERM rather than SIGHUP does seem more appropriate for this
case in general.  However, it might not work well for PostgreSQL.

PostgreSQL has three modes of shutdown (that I know of):  SIGTERM
triggers a "smart" shutdown mode that will wait for clients to
disconnect first; SIGINT triggers "fast" shutdown that aborts current
transactions and shuts down cleanly very quickly; SIGQUIT triggers
"immediate" shutdown that quits with minimal attempt to clean up
first, leading to recovery on the next restart.  Unfortunately for our
case, the SIGTERM mode is not appropriate for system shutdown because
we would block until interactive clients all happen to disconnect,
which is likely to cause the win32 system to just kill the postgresql
processes after it waits the maximum allowed time for services to

Cygrunsrv can send an arbitrary signal to the managed process in the
event of system shutdown, and I configure it to send SIGINT for
PostgreSQL to trigger smart shutdown.  The problem, as I see it, is
that there is a race condition and if we have Cygwin send SIGTERM
rather than SIGHUP then the PostgreSQL processes may get that before
the SIGINT sent by cygrunsrv and will embark on the smart shutdown
path.  I believe (but, I realize, I'm not sure) that PostgreSQL will
continue with the "smart" shutdown even on later receipt of SIGINT.

A Unix system would typically give daemon processes a chance to
shutdown cleanly between run-levels through the use of /etc/init.d
scripts (or the like), before hammering them with a signal.
Cygrunsrv's --shutdown option gives us a limited capability similar to
those init.d scripts, but unfortunately doesn't get the same priority
in time that the scripts get.

Fred Yankowski           fred(at)OntoSys(dot)com      tel: +1.630.879.1312
Principal Consultant       fax: +1.630.879.1370
OntoSys, Inc             38W242 Deerpath Rd, Batavia, IL 60510, USA

In response to

pgsql-cygwin by date

Next:From: Jason TishlerDate: 2001-07-16 20:41:28
Subject: Re: PostgreSQL on Cygwin
Previous:From: Fred YankowskiDate: 2001-07-16 16:34:16
Subject: Re: [ANNOUNCEMENT] Updated: cygrunsrv-0.94-1

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group