github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/util_unix.go (about)

     1  //go:build !windows
     2  
     3  package main
     4  
     5  // This file contains utility functions for Unix-like systems (e.g. Linux).
     6  
     7  import (
     8  	"os/exec"
     9  	"syscall"
    10  )
    11  
    12  // setCommandAsDaemon makes sure this command does not receive signals sent to
    13  // the parent.
    14  func setCommandAsDaemon(daemon *exec.Cmd) {
    15  	// https://stackoverflow.com/a/35435038/559350
    16  	daemon.SysProcAttr = &syscall.SysProcAttr{
    17  		Setpgid: true,
    18  		Pgid:    0,
    19  	}
    20  }