github.com/BIG5Concepts/forego@v0.16.1/unix.go (about)

     1  // +build darwin freebsd linux netbsd openbsd
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"path/filepath"
     8  	"syscall"
     9  )
    10  
    11  const osHaveSigTerm = true
    12  
    13  func ShellInvocationCommand(interactive bool, root, command string) []string {
    14  	shellArgument := "-c"
    15  	if interactive {
    16  		shellArgument = "-ic"
    17  	}
    18  	profile := filepath.Join(root, ".profile")
    19  	shellCommand := fmt.Sprintf("source \"%s\" 2>/dev/null; %s", profile, command)
    20  	return []string{"/bin/bash", shellArgument, shellCommand}
    21  
    22  }
    23  
    24  func (p *Process) PlatformSpecificInit() {
    25  	if !p.Interactive {
    26  		p.SysProcAttr = &syscall.SysProcAttr{}
    27  		p.SysProcAttr.Setsid = true
    28  	}
    29  	return
    30  }
    31  
    32  func (p *Process) SendSigTerm() {
    33  	p.Signal(syscall.SIGTERM)
    34  }
    35  
    36  func (p *Process) SendSigKill() {
    37  	p.Signal(syscall.SIGKILL)
    38  }