command_unix.go 457 B

1234567891011121314151617181920212223
  1. // +build freebsd darwin
  2. package reexec
  3. import (
  4. "os/exec"
  5. )
  6. // Self returns the path to the current process's binary.
  7. // Uses os.Args[0].
  8. func Self() string {
  9. return naiveSelf()
  10. }
  11. // Command returns *exec.Cmd which has Path as current binary.
  12. // For example if current binary is "docker" at "/usr/bin/", then cmd.Path will
  13. // be set to "/usr/bin/docker".
  14. func Command(args ...string) *exec.Cmd {
  15. return &exec.Cmd{
  16. Path: Self(),
  17. Args: args,
  18. }
  19. }