]> Cypherpunks repositories - gostls13.git/commitdiff
Replicate signal names from syscall in os/signal.
authorDavid Symonds <dsymonds@golang.org>
Mon, 11 Jan 2010 19:23:46 +0000 (11:23 -0800)
committerRuss Cox <rsc@golang.org>
Mon, 11 Jan 2010 19:23:46 +0000 (11:23 -0800)
R=rsc
CC=golang-dev
https://golang.org/cl/183142

.hgignore
src/pkg/os/signal/Makefile
src/pkg/os/signal/mkunix.sh [new file with mode: 0755]
src/pkg/os/signal/signal_test.go

index c739a20b7fa3bc691cb568a77b3f1704ede1b402..7e039d12bda152fb8ac198db789ee99cd471d9cd 100644 (file)
--- a/.hgignore
+++ b/.hgignore
@@ -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.*
index a1f04b6e181f062af99c43575fa6bde372ce3f2a..5a245464a05b23dd72274de806ce711db725b3f2 100644 (file)
@@ -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 $@
diff --git a/src/pkg/os/signal/mkunix.sh b/src/pkg/os/signal/mkunix.sh
new file mode 100755 (executable)
index 0000000..e1ea660
--- /dev/null
@@ -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 ")"
index 27336cc1892956248144dbcbaa95b04b6375c59f..f2679f14dc6a13b3bc92504dbc3cb272566ac9ab 100644 (file)
@@ -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)
        }
 }