This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ctrl_c_handler() vs. cygrunsrv shutdown handling problem


On Thu, May 29, 2003 at 01:12:36PM -0400, Jason Tishler wrote:
> The SIGTERM signal sent by Cygwin's ctrl_c_handler() is interfering
> with cygrunsrv's shutdown handling -- at least for PostgreSQL.  See
> the attached for an example of this problem.
> 
> [snip]
> 
> I'm willing to work up a patch to fix this problem properly.
> Unfortunately, the only solution I can think of is a new CYGWIN
> setting.  Is this acceptable?  If not, any other ideas?

After more reflection, I propose the attached patch as a solution to the
problem.  In short, I feel that the best (i.e., most general) solution
to the problem is to leave it up to the individual daemon to handle
shutdown events and not hardcode this behavior into the Cygwin DLL.

The following is a more detailed explanation of my reasoning:

    1. The MSDN states the following:

       CTRL_SHUTDOWN_EVENT:

       Note that this signal is received only by services. Interactive
       applications are terminated at logoff, so they are not present
       when the system sends this signal. Services also have their own
       notification mechanism for shutdown events. For more information,
       see Handler. [1]

    2. Unix daemons ported to Cygwin will either run as a native NT
       service (e.g., inetd) or under cygrunsrv (e.g., sshd). [2]

The above implies the current ctrl_c_handler() CTRL_SHUTDOWN_EVENT code
is:

    1. invoked only for services -- never for normal applications
    2. redundant since services have their own notification mechanism

Hence, I feel the hardcoded ctrl_c_handler() CTRL_SHUTDOWN_EVENT code
should be removed, giving daemons full control over their shutdown
behavior.

Do others agree?  If so, then I'm willing to submit this patch (and the
associated ChangeLog) to cygwin-patches@.  Additionally, I'm will to
patch inetd to handle shutdown events too.  If not, then please help me
resolve this issue.

Thanks,
Jason

Notes:

[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/handlerroutine.asp
[2] NT/2000/XP only

-- 
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Attachment: exceptions.cc.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]