File: reexec_other.go

package info (click to toggle)
golang-github-moby-sys 0.0~git20250819.9dc3a90-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 708 kB
  • sloc: makefile: 58
file content (26 lines) | stat: -rw-r--r-- 672 bytes parent folder | download
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
//go:build !linux

package reexec

import (
	"context"
	"os/exec"
)

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:]
	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:]
	return cmd
}