1
0
mirror of https://github.com/golang/go synced 2024-11-19 02:44:44 -07:00
go/src/syscall
Tianon Gravi 5d1a95175e runtime: treat CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT as SIGTERM on Windows
This matches the existing behavior of treating CTRL_C_EVENT, CTRL_BREAK_EVENT as a synthesized SIGINT event.

See https://docs.microsoft.com/en-us/windows/console/handlerroutine for a good documentation source upstream to confirm these values.

As for the usage of these events, the "Timeouts" section of that upstream documentation is important to note, especially the limited window in which to do any cleanup before the program will be forcibly killed (defaults typically 5s, but as low as 500ms, and in many cases configurable system-wide).

These events are especially relevant for Windows containers, where these events (particularly `CTRL_SHUTDOWN_EVENT`) are one of the only ways containers can "gracefully" shut down (https://github.com/moby/moby/issues/25982#issuecomment-466804071).

This was verified by making a simple `main()` which implements the same code as in `ExampleNotify_allSignals` but in a `for` loop, building a `main.exe`, running that in a container, then doing `docker kill -sTERM` on said container.  The program prints `Got signal: SIGTERM`, then exits after the aforementioned timeout, as expected.  Behavior before this patch is that the program gets no notification (and thus no output) but still exits after the timeout.

Fixes #7479

Change-Id: I2af79421cd484a0fbb9467bb7ddb5f0e8bc3610e
GitHub-Last-Rev: 9e05d631b5
GitHub-Pull-Request: golang/go#33311
Reviewed-on: https://go-review.googlesource.com/c/go/+/187739
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2019-08-29 08:15:20 +00:00
..
js runtime,syscall/js: reuse wasm memory DataView 2019-08-28 05:11:20 +00:00
asm9_unix1_amd64.s
asm9_unix2_amd64.s syscall: fix vet complaints for all dragonfly, freebsd, netbsd, openbsd 2019-05-09 21:13:25 +00:00
asm_aix_ppc64.s syscall: remove linknames to runtime symbols for aix/ppc64 2018-12-14 09:10:02 +00:00
asm_darwin_386.s
asm_darwin_amd64.s
asm_darwin_arm64.s
asm_darwin_arm.s
asm_freebsd_arm.s
asm_linux_386.s
asm_linux_amd64.s
asm_linux_arm64.s
asm_linux_arm.s
asm_linux_mips64x.s
asm_linux_mipsx.s
asm_linux_ppc64x.s syscall: implement rawVforkSyscall for linux/ppc64x and linux/s390x 2019-05-15 18:12:10 +00:00
asm_linux_s390x.s syscall: implement rawVforkSyscall for linux/ppc64x and linux/s390x 2019-05-15 18:12:10 +00:00
asm_nacl_386.s all: this big patch remove whitespace from assembly files 2018-10-03 15:28:51 +00:00
asm_nacl_amd64p32.s all: this big patch remove whitespace from assembly files 2018-10-03 15:28:51 +00:00
asm_nacl_arm.s all: this big patch remove whitespace from assembly files 2018-10-03 15:28:51 +00:00
asm_netbsd_arm64.s all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
asm_netbsd_arm.s syscall: fix vet complaints for all dragonfly, freebsd, netbsd, openbsd 2019-05-09 21:13:25 +00:00
asm_openbsd_arm64.s runtime, syscall: address vet errors in openbsd/arm64 assembly 2019-04-27 18:05:25 +00:00
asm_openbsd_arm.s
asm_plan9_386.s all: this big patch remove whitespace from assembly files 2018-10-03 15:28:51 +00:00
asm_plan9_amd64.s all: this big patch remove whitespace from assembly files 2018-10-03 15:28:51 +00:00
asm_plan9_arm.s
asm_solaris_amd64.s syscall: change solaris files to libc files 2018-10-10 00:58:17 +00:00
asm_unix_386.s syscall: fix vet complaints for all dragonfly, freebsd, netbsd, openbsd 2019-05-09 21:13:25 +00:00
asm_unix_amd64.s
asm_windows.s runtime: correct ABI information for all functions 2018-11-12 20:27:18 +00:00
bpf_bsd.go syscall: move uses of Syscall to libSystem on darwin 2018-11-08 03:01:54 +00:00
bpf_darwin.go syscall: move uses of Syscall to libSystem on darwin 2018-11-08 03:01:54 +00:00
const_plan9.go
creds_test.go
dir_plan9.go
dirent_test.go syscall: enable ReadDirent tests on aix, linux and solaris 2019-08-29 06:41:00 +00:00
dirent.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
dll_windows.go syscall: refer to Proc.Call documentation for LazyProc.Call on Windows 2019-06-07 17:22:53 +00:00
endian_big.go
endian_little.go
env_plan9.go
env_unix.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
env_windows.go
errors_plan9.go
exec_aix_test.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
exec_bsd.go Revert "syscall: use Ctty before fd shuffle" 2019-06-27 16:53:02 +00:00
exec_darwin.go Revert "syscall: use Ctty before fd shuffle" 2019-06-27 16:53:02 +00:00
exec_libc.go Revert "syscall: use Ctty before fd shuffle" 2019-06-27 16:53:02 +00:00
exec_linux_test.go syscall: fix skip condition in skipUnprivilegedUserClone 2019-06-06 11:40:17 +00:00
exec_linux.go Revert "syscall: use Ctty before fd shuffle" 2019-06-27 16:53:02 +00:00
exec_plan9.go
exec_solaris_test.go
exec_unix_test.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
exec_unix.go all: add new GOOS=illumos, split out of GOOS=solaris 2019-04-30 16:59:13 +00:00
exec_windows.go syscall: allow setting security attributes on processes 2019-04-28 05:44:03 +00:00
export_freebsd_test.go syscall: swap src, dest arguments in convertFromDirents11 for FreeBSD 2018-10-24 15:43:41 +00:00
export_linux_test.go
export_test.go
export_unix_test.go
fd_nacl.go
flock_aix.go syscall, cmd/go/internal/lockedfile: remove Flock syscall for aix/ppc64 2018-12-04 14:37:14 +00:00
flock_darwin.go syscall: move uses of Syscall to libSystem on darwin 2018-11-08 03:01:54 +00:00
flock_linux_32bit.go
flock.go syscall: move uses of Syscall to libSystem on darwin 2018-11-08 03:01:54 +00:00
forkpipe2.go Revert "syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe" 2018-08-26 21:30:35 +00:00
forkpipe.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
fs_js.go syscall/js: replace TypedArrayOf with CopyBytesToGo/CopyBytesToJS 2019-05-24 09:38:37 +00:00
fs_nacl.go
getdirentries_test.go all: shorten some tests 2019-05-22 12:54:00 +00:00
lsf_linux.go
mkall.sh syscall: support generating netbsd/arm64 files in mkall.sh 2019-05-05 12:55:21 +00:00
mkasm_darwin.go syscall: move uses of Syscall to libSystem on darwin 2018-11-08 03:01:54 +00:00
mkerrors.sh syscall: add aix to syscall_unix_test.go 2019-04-12 16:18:12 +00:00
mkpost.go syscall: revert to pre-FreeBSD 10 / POSIX-2008 timespec field names in Stat_t on FreeBSD 2018-12-30 19:36:52 +00:00
mksyscall_libc.pl syscall: add marker comments to zsyscall_{aix,solaris}_*.go 2018-10-10 18:42:21 +00:00
mksyscall_windows.go all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
mksyscall.pl syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
mksysctl_openbsd.pl
mksysnum_darwin.pl
mksysnum_dragonfly.pl
mksysnum_freebsd.pl
mksysnum_linux.pl
mksysnum_netbsd.pl
mksysnum_openbsd.pl
mksysnum_plan9.sh
mmap_unix_test.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
msan0.go
msan.go
net_js.go
net_nacl.go
net.go os: add SyscallConn method for os.File 2018-12-27 16:36:34 +00:00
netlink_linux.go
pwd_plan9.go
route_bsd.go
route_darwin.go
route_dragonfly.go
route_freebsd_32bit.go syscall: FreeBSD 12 ino64 support 2018-10-05 21:38:13 +00:00
route_freebsd_64bit.go
route_freebsd.go syscall: FreeBSD 12 ino64 support 2018-10-05 21:38:13 +00:00
route_netbsd.go
route_openbsd.go
security_windows.go runtime: safely load DLLs 2019-03-10 05:40:13 +00:00
setuidgid_32_linux.go
setuidgid_linux.go
sockcmsg_linux.go
sockcmsg_unix.go all: add new GOOS=illumos, split out of GOOS=solaris 2019-04-30 16:59:13 +00:00
str.go
syscall_aix_ppc64.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
syscall_aix.go syscall: add aix to syscall_unix_test.go 2019-04-12 16:18:12 +00:00
syscall_bsd_test.go
syscall_bsd.go syscall: implement syscalls on Darwin using libSystem 2018-11-07 20:27:01 +00:00
syscall_darwin_386.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
syscall_darwin_amd64.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
syscall_darwin_arm64.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
syscall_darwin_arm.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
syscall_darwin.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
syscall_dragonfly_amd64.go
syscall_dragonfly.go syscall: implement syscalls on Darwin using libSystem 2018-11-07 20:27:01 +00:00
syscall_freebsd_386.go
syscall_freebsd_amd64.go
syscall_freebsd_arm.go
syscall_freebsd_test.go syscall: swap src, dest arguments in convertFromDirents11 for FreeBSD 2018-10-24 15:43:41 +00:00
syscall_freebsd.go syscall: include complete prototype of system calls 2019-08-05 19:01:06 +00:00
syscall_getwd_bsd.go
syscall_js.go syscall: document relationship among Errno, errors.Is and os.Err* 2019-08-22 20:06:29 +00:00
syscall_linux_386.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_amd64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_arm64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_arm.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_mips64x.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_mipsx.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_ppc64x.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_s390x.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_linux_test.go syscall: skip TestSyscallNoError when temp dir is mounted nosuid 2019-02-15 19:24:37 +00:00
syscall_linux.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
syscall_nacl_386.go
syscall_nacl_amd64p32.go
syscall_nacl_arm.go
syscall_nacl.go syscall: document relationship among Errno, errors.Is and os.Err* 2019-08-22 20:06:29 +00:00
syscall_netbsd_386.go
syscall_netbsd_amd64.go
syscall_netbsd_arm64.go all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
syscall_netbsd_arm.go
syscall_netbsd.go syscall: implement syscalls on Darwin using libSystem 2018-11-07 20:27:01 +00:00
syscall_openbsd_386.go
syscall_openbsd_amd64.go
syscall_openbsd_arm64.go syscall: add support for openbsd/arm64 2019-04-26 17:34:54 +00:00
syscall_openbsd_arm.go
syscall_openbsd.go syscall: implement syscalls on Darwin using libSystem 2018-11-07 20:27:01 +00:00
syscall_plan9_test.go
syscall_plan9.go syscall: document relationship among Errno, errors.Is and os.Err* 2019-08-22 20:06:29 +00:00
syscall_ptrace_test.go syscall: accept permission errors in TestExecPtrace 2019-06-16 20:04:54 +00:00
syscall_solaris_amd64.go
syscall_solaris.go
syscall_test.go
syscall_unix_test.go syscall: move helper handler before AIX handler in TestPassFD 2019-04-16 13:25:16 +00:00
syscall_unix.go syscall: document relationship among Errno, errors.Is and os.Err* 2019-08-22 20:06:29 +00:00
syscall_windows_386.go
syscall_windows_amd64.go
syscall_windows_test.go
syscall_windows.go syscall: document relationship among Errno, errors.Is and os.Err* 2019-08-22 20:06:29 +00:00
syscall.go
tables_nacljs.go
time_nacl_386.s
time_nacl_amd64p32.s
time_nacl_arm.s
timestruct.go syscall: add AIX operating system 2018-10-10 04:29:55 +00:00
types_aix.go syscall: on AIX use nsendmsg and nrecvmsg, define SockaddrDatalink 2019-04-03 14:36:41 +00:00
types_darwin.go
types_dragonfly.go
types_freebsd.go syscall: FreeBSD 12 ino64 support 2018-10-05 21:38:13 +00:00
types_linux.go
types_netbsd.go
types_openbsd.go
types_solaris.go syscall: fix TestForeground for AIX 2018-10-25 16:03:56 +00:00
types_windows_386.go
types_windows_amd64.go
types_windows_arm.go
types_windows.go runtime: treat CTRL_CLOSE_EVENT, CTRL_LOGOFF_EVENT, CTRL_SHUTDOWN_EVENT as SIGTERM on Windows 2019-08-29 08:15:20 +00:00
unzip_nacl.go
zerrors_aix_ppc64.go syscall: add aix to syscall_unix_test.go 2019-04-12 16:18:12 +00:00
zerrors_darwin_386.go
zerrors_darwin_amd64.go
zerrors_darwin_arm64.go
zerrors_darwin_arm.go
zerrors_dragonfly_amd64.go
zerrors_freebsd_386.go
zerrors_freebsd_amd64.go
zerrors_freebsd_arm.go
zerrors_linux_386.go
zerrors_linux_amd64.go
zerrors_linux_arm64.go
zerrors_linux_arm.go
zerrors_linux_mips64.go
zerrors_linux_mips64le.go
zerrors_linux_mips.go
zerrors_linux_mipsle.go
zerrors_linux_ppc64.go
zerrors_linux_ppc64le.go
zerrors_linux_s390x.go
zerrors_netbsd_386.go
zerrors_netbsd_amd64.go
zerrors_netbsd_arm64.go all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
zerrors_netbsd_arm.go
zerrors_openbsd_386.go
zerrors_openbsd_amd64.go
zerrors_openbsd_arm64.go syscall: add support for openbsd/arm64 2019-04-26 17:34:54 +00:00
zerrors_openbsd_arm.go
zerrors_solaris_amd64.go
zerrors_windows_386.go
zerrors_windows_amd64.go
zerrors_windows.go
zsyscall_aix_ppc64.go syscall: add aix to syscall_unix_test.go 2019-04-12 16:18:12 +00:00
zsyscall_darwin_386.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_386.s syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_amd64.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_amd64.s syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_arm64.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_arm64.s syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_arm.go syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_darwin_arm.s syscall: disable ptrace on iOS 2019-06-15 14:23:04 +00:00
zsyscall_dragonfly_amd64.go Revert "syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe" 2018-08-26 21:30:35 +00:00
zsyscall_freebsd_386.go syscall: fix Getdirentries on 32-bit freebsd 12 2019-06-10 16:18:32 +00:00
zsyscall_freebsd_amd64.go syscall: fix Getdirentries on 32-bit freebsd 12 2019-06-10 16:18:32 +00:00
zsyscall_freebsd_arm.go syscall: fix Getdirentries on 32-bit freebsd 12 2019-06-10 16:18:32 +00:00
zsyscall_linux_386.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_amd64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_arm64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_arm.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_mips64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_mips64le.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_mips.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_mipsle.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_ppc64.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_ppc64le.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_linux_s390x.go syscall: move Renameat to syscall_linux_$GOARCH.go 2019-08-28 15:44:01 +00:00
zsyscall_nacl_386.go
zsyscall_nacl_amd64p32.go
zsyscall_nacl_arm.go
zsyscall_netbsd_386.go
zsyscall_netbsd_amd64.go
zsyscall_netbsd_arm64.go all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
zsyscall_netbsd_arm.go
zsyscall_openbsd_386.go
zsyscall_openbsd_amd64.go
zsyscall_openbsd_arm64.go syscall: add support for openbsd/arm64 2019-04-26 17:34:54 +00:00
zsyscall_openbsd_arm.go
zsyscall_plan9_386.go
zsyscall_plan9_amd64.go
zsyscall_plan9_arm.go
zsyscall_solaris_amd64.go syscall: add marker comments to zsyscall_{aix,solaris}_*.go 2018-10-10 18:42:21 +00:00
zsyscall_windows.go runtime: safely load DLLs 2019-03-10 05:40:13 +00:00
zsysctl_openbsd.go
zsysnum_darwin_386.go
zsysnum_darwin_amd64.go
zsysnum_darwin_arm64.go
zsysnum_darwin_arm.go
zsysnum_dragonfly_amd64.go Revert "syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe" 2018-08-26 21:30:35 +00:00
zsysnum_freebsd_386.go
zsysnum_freebsd_amd64.go
zsysnum_freebsd_arm.go
zsysnum_linux_386.go
zsysnum_linux_amd64.go
zsysnum_linux_arm64.go
zsysnum_linux_arm.go
zsysnum_linux_mips64.go
zsysnum_linux_mips64le.go
zsysnum_linux_mips.go
zsysnum_linux_mipsle.go
zsysnum_linux_ppc64.go
zsysnum_linux_ppc64le.go
zsysnum_linux_s390x.go
zsysnum_netbsd_386.go
zsysnum_netbsd_amd64.go
zsysnum_netbsd_arm64.go all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
zsysnum_netbsd_arm.go
zsysnum_openbsd_386.go
zsysnum_openbsd_amd64.go
zsysnum_openbsd_arm64.go syscall: add support for openbsd/arm64 2019-04-26 17:34:54 +00:00
zsysnum_openbsd_arm.go
zsysnum_plan9.go
zsysnum_solaris_amd64.go
zsysnum_windows_386.go
zsysnum_windows_amd64.go
ztypes_aix_ppc64.go syscall: on AIX use nsendmsg and nrecvmsg, define SockaddrDatalink 2019-04-03 14:36:41 +00:00
ztypes_darwin_386.go
ztypes_darwin_amd64.go
ztypes_darwin_arm64.go
ztypes_darwin_arm.go
ztypes_dragonfly_amd64.go
ztypes_freebsd_386.go syscall: revert to pre-FreeBSD 10 / POSIX-2008 timespec field names in Stat_t on FreeBSD 2018-12-30 19:36:52 +00:00
ztypes_freebsd_amd64.go syscall: revert to pre-FreeBSD 10 / POSIX-2008 timespec field names in Stat_t on FreeBSD 2018-12-30 19:36:52 +00:00
ztypes_freebsd_arm.go syscall: revert to pre-FreeBSD 10 / POSIX-2008 timespec field names in Stat_t on FreeBSD 2018-12-30 19:36:52 +00:00
ztypes_linux_386.go
ztypes_linux_amd64.go
ztypes_linux_arm64.go
ztypes_linux_arm.go
ztypes_linux_mips64.go
ztypes_linux_mips64le.go
ztypes_linux_mips.go
ztypes_linux_mipsle.go
ztypes_linux_ppc64.go
ztypes_linux_ppc64le.go
ztypes_linux_s390x.go
ztypes_netbsd_386.go
ztypes_netbsd_amd64.go
ztypes_netbsd_arm64.go all: add start of netbsd/arm64 support 2019-04-20 15:02:01 +00:00
ztypes_netbsd_arm.go
ztypes_openbsd_386.go
ztypes_openbsd_amd64.go
ztypes_openbsd_arm64.go syscall: add support for openbsd/arm64 2019-04-26 17:34:54 +00:00
ztypes_openbsd_arm.go syscall: regenerate ztypes for openbsd/arm 2018-12-12 02:35:39 +00:00
ztypes_solaris_amd64.go syscall: fix TestForeground for AIX 2018-10-25 16:03:56 +00:00