Home | History | Annotate | Download | only in testprog
      1 // Copyright 2015 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // +build !windows,!plan9,!nacl
      6 
      7 package main
      8 
      9 import (
     10 	"syscall"
     11 	"time"
     12 )
     13 
     14 func init() {
     15 	register("SignalExitStatus", SignalExitStatus)
     16 }
     17 
     18 func SignalExitStatus() {
     19 	syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
     20 
     21 	// Should die immediately, but we've seen flakiness on various
     22 	// systems (see issue 14063). It's possible that the signal is
     23 	// being delivered to a different thread and we are returning
     24 	// and exiting before that thread runs again. Give the program
     25 	// a little while to die to make sure we pick up the signal
     26 	// before we return and exit the program. The time here
     27 	// shouldn't matter--we'll never really sleep this long.
     28 	time.Sleep(time.Second)
     29 }
     30