mirror of
https://github.com/SDL-Hercules-390/hyperion.git
synced 2026-04-20 18:57:06 +02:00
Implement SIGTERM handler
If a SIGTERM is received hercules will now send a signal to a running client OS to shut down and wait for that to complete before terminating. Not all client OSes necessarily support this. Hercules can still be forced to terminate immediately using SIGKILL. git-svn-id: file:///home/jj/hercules.svn/trunk@5669 956126f8-22a0-4046-8f4a-272fa8102e63
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,5 +1,6 @@
|
||||
10 Mar 2010 Add SIGTERM handler to cleanly shut down clients - Frans Pop
|
||||
16 Feb 2010 Fix Conditional SSKE failing with Storage Key Assist - Ivan Warren
|
||||
04 Feb 2010 - Fix building on 64-bit Macs under Snow Leopard - Jay Maynard
|
||||
04 Feb 2010 Fix building on 64-bit Macs under Snow Leopard - Jay Maynard
|
||||
16 Dec 2009 Fix S/370 SIE guests - Ivan Warren
|
||||
14 Jun 2009 uptime command - Fish
|
||||
14 Jun 2009 Support expanded storage sizes exceeding 4GB (64-bit only) - Roger Bowler
|
||||
|
||||
@@ -403,6 +403,7 @@ struct SYSBLK {
|
||||
BYTE *xpndstor; /* -> Expanded storage */
|
||||
U64 todstart; /* Time of initialisation */
|
||||
U64 cpuid; /* CPU identifier for STIDP */
|
||||
TID impltid; /* Thread-id for main progr. */
|
||||
TID wdtid; /* Thread-id for watchdog */
|
||||
U16 lparnuml; /* #digits (0-2) in lparnum */
|
||||
U16 lparnum; /* LPAR identification number*/
|
||||
|
||||
@@ -116,6 +116,18 @@ HHCIN008S DYNGUI.DLL load failed; Hercules terminated.
|
||||
<dt>Issued by
|
||||
<dd>impl.c, function main
|
||||
</dl>
|
||||
<dt><code><a name="HHCIN009S">
|
||||
HHCIN009S Cannot register SIGTERM handler: <em>error</em>
|
||||
</a></code>
|
||||
<dd><dl>
|
||||
<dt>Meaning
|
||||
<dd>An attempt to register a handler for the SIGTERM signal failed. The
|
||||
error is described by <code><em>error</em></code>.
|
||||
<dt>Action
|
||||
<dd>Correct the error and restart Hercules.
|
||||
<dt>Issued by
|
||||
<dd>impl.c, function main
|
||||
</dl>
|
||||
<dt><code><a name="HHCIN099I">
|
||||
HHCIN099I Hercules terminated
|
||||
</a></code>
|
||||
|
||||
32
impl.c
32
impl.c
@@ -109,6 +109,27 @@ static void sigint_handler (int signo)
|
||||
return;
|
||||
} /* end function sigint_handler */
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
/* Signal handler for SIGTERM signal */
|
||||
/*-------------------------------------------------------------------*/
|
||||
static void sigterm_handler (int signo)
|
||||
{
|
||||
// logmsg ("config: sigterm handler entered for thread %lu\n",/*debug*/
|
||||
// thread_id()); /*debug*/
|
||||
|
||||
UNREFERENCED(signo);
|
||||
|
||||
signal(SIGTERM, sigterm_handler);
|
||||
/* Ignore signal unless presented on main program (impl) thread */
|
||||
if ( !equal_threads( thread_id(), sysblk.impltid ) )
|
||||
return;
|
||||
|
||||
/* Initiate system shutdown */
|
||||
do_shutdown();
|
||||
|
||||
return;
|
||||
} /* end function sigterm_handler */
|
||||
|
||||
|
||||
#if !defined(NO_SIGABEND_HANDLER)
|
||||
static void *watchdog_thread(void *arg)
|
||||
@@ -290,6 +311,9 @@ TID logcbtid; /* RC file thread identifier */
|
||||
/* Clear the system configuration block */
|
||||
memset (&sysblk, 0, sizeof(SYSBLK));
|
||||
|
||||
/* Save thread ID of main program */
|
||||
sysblk.impltid = thread_id();
|
||||
|
||||
/* Save TOD of when we were first IMPL'ed */
|
||||
time( &sysblk.impltime );
|
||||
|
||||
@@ -432,6 +456,14 @@ TID logcbtid; /* RC file thread identifier */
|
||||
delayed_exit(1);
|
||||
}
|
||||
|
||||
/* Register the SIGTERM handler */
|
||||
if ( signal (SIGTERM, sigterm_handler) == SIG_ERR )
|
||||
{
|
||||
logmsg(_("HHCIN009S Cannot register SIGTERM handler: %s\n"),
|
||||
strerror(errno));
|
||||
delayed_exit(1);
|
||||
}
|
||||
|
||||
#if defined(HAVE_DECL_SIGPIPE) && HAVE_DECL_SIGPIPE
|
||||
/* Ignore the SIGPIPE signal, otherwise Hercules may terminate with
|
||||
Broken Pipe error if the printer driver writes to a closed pipe */
|
||||
|
||||
Reference in New Issue
Block a user