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

cygrunsrv patch for system shutdown handling

From: Fred Yankowski <fcy(at)ontosys(dot)com>
To: cygwin-apps(at)cygwin(dot)com
Cc: pgsql-cygwin(at)postgresql(dot)org
Subject: cygrunsrv patch for system shutdown handling
Date: 2001-06-15 19:47:56
Message-ID: 3B2A666C.932B5FB7@ontosys.com (view raw or flat)
Thread:
Lists: pgsql-cygwin
Attached is a patch to cygrunsrv that adds an optional feature where
cygrunsrv accepts SERVICE_CONTROL_SHUTDOWN notifications from the
Service Control Manager and explicitly terminates the managed
application process on receipt of such a notification.  This gives the
application a chance to shutdown cleanly, just as it does during a
manual stop ("net stop").

This feature is useful with the Cygwin port of PostgreSQL.  Without this
feature it seems that the abrupt termination of the postmaster process
during system shutdown leaves the PostgreSQL data in a state where
postmaster cannot start up without manual intervention (the
postmaster.pid file, in particular).  Note that postmaster/postgres must
also ignore SIGHUP signals for this to work -- a separate patch.

The bulk of the patch is the usual stuff to enable a new command line
option and manage the registry value.  The interesting part of the code
is merely the new set_service_controls_accepted() function that enables
the service to accept the shutdown control, and the change to
service_handler() that treats the SERVICE_CONTROL_SHUTDOWN notification
exactly like SERVICE_CONTROL_STOP.  More elaborate handling of the
shutdown case is possible, such as sending STOP_PENDING messages until
the managed process actually terminates, but in practice this simple
scheme works just fine (for PostgreSQL at least).

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

Attachment: cygrunsrv.changelog
Description: text/plain (1.3 KB)
Attachment: cygrunsrv.diff
Description: text/plain (7.5 KB)

pgsql-cygwin by date

Next:From: Dmitry YurtaevDate: 2001-06-16 16:55:15
Subject: Re: Service reboot leaves postmaster.pid
Previous:From: Fred YankowskiDate: 2001-06-15 16:53:41
Subject: Re: Service reboot leaves postmaster.pid

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