You caught and ignored the interrupt signal. Wasn't that
what you wanted to do?
Chris
--
Chris "allusive" Dollin
At caughting os.Interrupt from a loop, it runs all code of that loop
but then, the program is finished.
go version weekly.2012-02-14 +43cf9b39b647
linux 64 bits
blame the kernel? unlikely the source for something this basic.
$ uname -a
Linux g 3.1.5-6.fc16.x86_64 #1 SMP Thu Dec 15 16:14:44 UTC 2011 x86_64
x86_64 x86_64 GNU/Linux
$ cd /tmp
$ cat > t.go
[your code]
$ go build t.go
$ ./t
press CTRL-C
^C
Caught: signal 2
code inner of loop
^C
Caught: signal 2
code inner of loop
^C
Caught: signal 2
code inner of loop
^C
Caught: signal 2
code inner of loop
^C
Caught: signal 2
code inner of loop
^\SIGQUIT: quit
PC=0x4157c7
os/signal.loop()
/go/src/pkg/os/signal/signal_unix.go:20 +0x1c
created by os/signal.init·1
/go/src/pkg/os/signal/signal_unix.go:26 +0x2f
What is most likely happening: you're using 'go run mycode.go', so
your signal is received by the go tool, which promptly exits. your
tool gets a sigpipe (most likely) which it doesn't know how to handle.
Do this test:
$ go run ...go
then in a separate window go "ps auwx | grep a.out", once you figure
out the process id of the a.out you can send _it_ the signal and
you'll see the expected behaviour:
$ kill -2 <pid>