cond +build signal

This commit is contained in:
xtaci
2016-06-01 11:12:48 +08:00
parent 400993f22e
commit 41358f41cc
4 changed files with 56 additions and 29 deletions
-15
View File
@@ -6,8 +6,6 @@ import (
"math/rand"
"net"
"os"
"os/signal"
"syscall"
"time"
"github.com/hashicorp/yamux"
@@ -52,7 +50,6 @@ func checkError(err error) {
func main() {
rand.Seed(int64(time.Now().Nanosecond()))
go sig_handler()
myApp := cli.NewApp()
myApp.Name = "kcptun"
myApp.Usage = "kcptun client"
@@ -181,15 +178,3 @@ func main() {
}
myApp.Run(os.Args)
}
func sig_handler() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGUSR1)
for {
switch <-ch {
case syscall.SIGUSR1:
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
}
}
}
+28
View File
@@ -0,0 +1,28 @@
// +build linux darwin freebsd
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/xtaci/kcp-go"
)
func init() {
go sig_handler()
}
func sig_handler() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGUSR1)
for {
switch <-ch {
case syscall.SIGUSR1:
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
}
}
}
-14
View File
@@ -6,8 +6,6 @@ import (
"math/rand"
"net"
"os"
"os/signal"
"syscall"
"time"
"github.com/hashicorp/yamux"
@@ -80,7 +78,6 @@ func handleClient(p1, p2 net.Conn) {
func main() {
rand.Seed(int64(time.Now().Nanosecond()))
go sig_handler()
myApp := cli.NewApp()
myApp.Name = "kcptun"
myApp.Usage = "kcptun server"
@@ -178,14 +175,3 @@ func main() {
}
myApp.Run(os.Args)
}
func sig_handler() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGUSR1)
for {
switch <-ch {
case syscall.SIGUSR1:
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
}
}
}
+28
View File
@@ -0,0 +1,28 @@
// +build linux darwin freebsd
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/xtaci/kcp-go"
)
func init() {
go sig_handler()
}
func sig_handler() {
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGUSR1)
for {
switch <-ch {
case syscall.SIGUSR1:
log.Printf("KCP SNMP:%+v", kcp.DefaultSnmp.Copy())
}
}
}