| 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; |
| } |