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: (view raw, whole thread or download thread mbox)
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 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       fax: +1.630.879.1370
OntoSys, Inc             38W242 Deerpath Rd, Batavia, IL 60510, USA

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

pgsql-cygwin by date

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

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