Golang 实现守护进程实例
package main import ( "log" func Agent(nochdir,noclose int) int { //already a daemon process //failure //hand exception for darwin //new process success,exit the parent process //change the filem mode mask //create the new SID for the child process if s_ret < 0 { //modify the process execute directory //redirect the IO stream func main() { fmt.Println("Hello,World.n") fmt.Println(os.Getpid()) fmt.Println("this is a first go program!") Agent(0,1) for { fmt.Println("hello") fmt.Println(os.Getpid()) time.Sleep(1 * time.Second) }} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |