mirror of
https://github.com/golang/go
synced 2024-11-02 11:50:30 +00:00
Replicate signal names from syscall in os/signal.
R=rsc CC=golang-dev https://golang.org/cl/183142
This commit is contained in:
parent
93d81fb747
commit
0ed728c48a
4 changed files with 33 additions and 2 deletions
|
@ -20,6 +20,7 @@ src/cmd/gc/mkbuiltin1
|
|||
src/cmd/gc/opnames.h
|
||||
src/pkg/Make.deps
|
||||
src/pkg/exp/ogle/ogle
|
||||
src/pkg/os/signal/unix.go
|
||||
src/pkg/runtime/cgo2c
|
||||
src/pkg/runtime/*/asm.h
|
||||
src/pkg/runtime/runtime.acid.*
|
||||
|
|
|
@ -7,5 +7,11 @@ include ../../../Make.$(GOARCH)
|
|||
TARG=os/signal
|
||||
GOFILES=\
|
||||
signal.go\
|
||||
unix.go\
|
||||
|
||||
CLEANFILES+=unix.go
|
||||
|
||||
include ../../../Make.pkg
|
||||
|
||||
unix.go: ../../syscall/zerrors_$(GOOS)_$(GOARCH).go
|
||||
./mkunix.sh $< > $@ || rm -f $@
|
||||
|
|
24
src/pkg/os/signal/mkunix.sh
Executable file
24
src/pkg/os/signal/mkunix.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
# Copyright 2010 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
echo '// ./mkunix.sh' "$1"
|
||||
echo '// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT'
|
||||
echo
|
||||
|
||||
cat <<EOH
|
||||
package signal
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var _ = syscall.Syscall // in case there are zero signals
|
||||
|
||||
const (
|
||||
EOH
|
||||
|
||||
sed -n 's/^[ ]*\(SIG[A-Z0-9][A-Z0-9]*\).*/ \1 = UnixSignal(syscall.\1)/p' "$1"
|
||||
|
||||
echo ")"
|
|
@ -13,7 +13,7 @@ func TestSignal(t *testing.T) {
|
|||
// Send this process a SIGHUP.
|
||||
syscall.Syscall(syscall.SYS_KILL, uintptr(syscall.Getpid()), syscall.SIGHUP, 0)
|
||||
|
||||
if sig := (<-Incoming).(UnixSignal); sig != 1 {
|
||||
t.Errorf("signal was %v, want %v", sig, 1)
|
||||
if sig := (<-Incoming).(UnixSignal); sig != SIGHUP {
|
||||
t.Errorf("signal was %v, want %v", sig, SIGHUP)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue