github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/pkg/reexec/command_linux.go (about) 1 // +build linux 2 3 package reexec 4 5 import ( 6 "os/exec" 7 "syscall" 8 ) 9 10 // Self returns the path to the current process's binary. 11 // Returns "/proc/self/exe". 12 func Self() string { 13 return "/proc/self/exe" 14 } 15 16 // Command returns *exec.Cmd which have Path as current binary. Also it setting 17 // SysProcAttr.Pdeathsig to SIGTERM. 18 // This will use the in-memory version (/proc/self/exe) of the current binary, 19 // it is thus safe to delete or replace the on-disk binary (os.Args[0]). 20 func Command(args ...string) *exec.Cmd { 21 return &exec.Cmd{ 22 Path: Self(), 23 Args: args, 24 SysProcAttr: &syscall.SysProcAttr{ 25 Pdeathsig: syscall.SIGTERM, 26 }, 27 } 28 }