github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgCmd/testPackage/testCmdChildren/main.go (about) 1 package main 2 3 import ( 4 //"os" 5 //"os/signal" 6 //"syscall" 7 "fmt" 8 "github.com/bronze1man/kmg/kmgConsole" 9 "time" 10 //"net/http" 11 //"github.com/bronze1man/kmg/kmgSys" 12 //"github.com/bronze1man/kmg/kmgCmd" 13 "github.com/bronze1man/kmg/kmgFile" 14 ) 15 16 func main() { 17 //go func(){ 18 // for { 19 // time.Sleep(time.Second) 20 // fmt.Println("sleep") 21 // } 22 //}() 23 //go func(){ 24 // err := http.ListenAndServe(":23456",nil) 25 // if err!=nil{ 26 // panic(err) 27 // } 28 //}() 29 //go func(){ 30 // tun,err:=kmgSys.NewTunNoName() 31 // if err!=nil{ 32 // panic(err) 33 // } 34 // buf:=make([]byte,4096) 35 // _,err=tun.Read(buf) 36 // if err!=nil{ 37 // panic(err) 38 // } 39 //}() 40 //kmgCmd.MustRun("ls") 41 kmgConsole.AddCommandWithName("cmd", cmd) 42 kmgConsole.Main() 43 } 44 45 func cmd() { 46 fmt.Println("children init finish") 47 kmgConsole.WaitForExit() 48 49 kmgFile.MustWriteFile("/tmp/2.log", []byte(time.Now().String())) 50 fmt.Println("children after WaitForExit") 51 time.Sleep(time.Second) 52 fmt.Println("children after sleep") 53 }