This is a creation in Article, where the information may have evolved or changed.
package mainimport ( "FMT" "OS" "Os/exec" "Path/filepath") Func main () { fmt. Println (OS. Getppid ()) if os. Getppid () != 1 { //determines if it is a child process, and when the parent process is return, the child process is System 1 process takes over filepath, _ := filepath. Abs (OS. Args[0]) //convert the execution file path in the command line argument to the available path cmd := exec. Command (FilePath) //to pass other commands into the generated process cmd. Stdin = os. stdin //to the new process settings file descriptor, can be redirected to the file cmd. Stdout = os. Stdout cmd.Stderr = os. stderr //start execution of new process without waiting for new process to exit cmd. Start () return }}
The daemon, the popular explanation, is the process of opening the Task Manager in Ctrl+alt+delete, which cannot be terminated by normal means. such as 360, Jinshan poison bully, but the way to protect the different.