2016-07-22 18:15:38 +00:00
|
|
|
// Copyright 2015 The Go Authors. All rights reserved.
|
2016-02-03 21:58:02 +00:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2022-02-11 14:53:56 -08:00
|
|
|
//go:build !windows && !plan9
|
2020-01-02 15:05:27 -08:00
|
|
|
// +build !windows,!plan9
|
2016-02-03 21:58:02 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
2016-07-22 18:15:38 +00:00
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"time"
|
|
|
|
)
|
2016-02-03 21:58:02 +00:00
|
|
|
|
|
|
|
func init() {
|
|
|
|
register("SignalExitStatus", SignalExitStatus)
|
|
|
|
}
|
|
|
|
|
|
|
|
func SignalExitStatus() {
|
|
|
|
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
2016-07-22 18:15:38 +00:00
|
|
|
|
|
|
|
// Should die immediately, but we've seen flakiness on various
|
|
|
|
// systems (see issue 14063). It's possible that the signal is
|
|
|
|
// being delivered to a different thread and we are returning
|
|
|
|
// and exiting before that thread runs again. Give the program
|
|
|
|
// a little while to die to make sure we pick up the signal
|
|
|
|
// before we return and exit the program. The time here
|
|
|
|
// shouldn't matter--we'll never really sleep this long.
|
|
|
|
time.Sleep(time.Second)
|
2016-02-03 21:58:02 +00:00
|
|
|
}
|