1
0
Fork 0
forked from External/grumble
grumble/signal_unix.go
2011-11-10 00:38:59 +01:00

29 lines
491 B
Go

// Copyright (c) 2011 The Grumble Authors
// The use of this source code is goverened by a BSD-style
// license that can be found in the LICENSE-file.
package main
import (
"fmt"
"os"
"os/signal"
)
func SignalHandler() {
for {
sig := <-signal.Incoming
if sig == os.SIGUSR2 {
err := LogTarget.Rotate()
if err != nil {
fmt.Fprintf(os.Stderr, "Unable to rotate log file: %v", err)
}
continue
}
if sig == os.SIGINT || sig == os.SIGTERM {
os.Exit(0)
}
}
}