github.com/searKing/golang/go@v1.2.117/syscall/setsid_unix.go (about)

     1  // Copyright 2022 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build !windows && !plan9 && !js
     6  
     7  package exec
     8  
     9  import "syscall"
    10  
    11  // SysProcAttrSetsid run a program in a new session, is used to detach the process from the parent (normally a shell)
    12  //
    13  // The disowning of a child process is accomplished by executing the system call
    14  // setpgrp() or setsid(), (both of which have the same functionality) as soon as
    15  // the child is forked. These calls create a new process session group, make the
    16  // child process the session leader, and set the process group ID to the process
    17  // ID of the child. https://bsdmag.org/unix-kernel-system-calls/
    18  func SysProcAttrSetsid(attr *syscall.SysProcAttr) {
    19  	attr.Setsid = true
    20  }