Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(127)

Unified Diff: src/pkg/runtime/os_windows.c

Issue 71900043: code review 71900043: runtime: Raise SIGTERM on receipt of CTRL_CLOSE_EVENT o...
Patch Set: diff -r 877a41585fc7 https://code.google.com/p/go Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pkg/runtime/defs_windows_386.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pkg/runtime/os_windows.c
===================================================================
--- a/src/pkg/runtime/os_windows.c
+++ b/src/pkg/runtime/os_windows.c
@@ -390,13 +390,30 @@
case CTRL_BREAK_EVENT:
s = SIGINT;
break;
+ case CTRL_CLOSE_EVENT:
+ // The console is first disconnected (SIGHUP), however it isn't
+ // possible to send two signals from this handler routine before
+ // returning. Therefore the louder signal is SIGTERM to warn of
+ // imminent termination.
+ s = SIGTERM;
+ break;
+ case CTRL_LOGOFF_EVENT:
+ case CTRL_SHUTDOWN_EVENT:
+ // These events are only received by services and represent OS-
+ // specific concepts that can't be mapped to generic signals.
default:
+ // Return FALSE to pass control to the next or default handler.
return 0;
}
if(runtime·sigsend(s))
return 1;
- runtime·exit(2); // SIGINT, SIGTERM, etc
+ // If we fail to notify a custom signal handler, then it's a choice
+ // between falling back onto default signal behaviour, or the next
+ // registered handler. Since failure to send the signal is an error, it's
+ // probably best just fall back on default SIGINT and SIGTERM behaviour
+ // which is to exit.
+ runtime·exit(2);
return 0;
}
« no previous file with comments | « src/pkg/runtime/defs_windows_386.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b