1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
package reexec
import (
"context"
"os/exec"
"syscall"
)
func command(args ...string) *exec.Cmd {
// We try to stay close to exec.Command's behavior, but after
// constructing the cmd, we remove "Self()" from cmd.Args, which
// is prepended by exec.Command.
cmd := exec.Command(Self(), args...)
cmd.Args = cmd.Args[1:]
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
}
return cmd
}
func commandContext(ctx context.Context, args ...string) *exec.Cmd {
// We try to stay close to exec.Command's behavior, but after
// constructing the cmd, we remove "Self()" from cmd.Args, which
// is prepended by exec.Command.
cmd := exec.CommandContext(ctx, Self(), args...)
cmd.Args = cmd.Args[1:]
cmd.SysProcAttr = &syscall.SysProcAttr{
Pdeathsig: syscall.SIGTERM,
}
return cmd
}
|