Skip to content

Commit 23e6066

Browse files
fvoznikashentubot
authored andcommitted
Remove detach for exec options
Detachable exec commands are handled in the client entirely and the detach option is not used anymore. PiperOrigin-RevId: 195181272
1 parent a4ba36e commit 23e6066

File tree

3 files changed

+2
-18
lines changed

3 files changed

+2
-18
lines changed

pkg/sentry/control/proc.go

-9
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ type ExecArgs struct {
7272
// Capabilities is the list of capabilities to give to the process.
7373
Capabilities *auth.TaskCapabilities
7474

75-
// Detach indicates whether Exec should detach once the process starts.
76-
Detach bool
77-
7875
// FilePayload determines the files to give to the new process.
7976
urpc.FilePayload
8077
}
@@ -135,12 +132,6 @@ func (proc *Proc) Exec(args *ExecArgs, waitStatus *uint32) error {
135132
return err
136133
}
137134

138-
// If we're supposed to detach, don't wait for the process to exit.
139-
if args.Detach {
140-
*waitStatus = 0
141-
return nil
142-
}
143-
144135
// Wait for completion.
145136
newTG.WaitExited()
146137
*waitStatus = newTG.ExitStatus().Status()

runsc/cmd/exec.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
9999
if err != nil {
100100
Fatalf("error parsing process spec: %v", err)
101101
}
102-
e.Detach = ex.detach
103102
conf := args[0].(*boot.Config)
104103
waitStatus := args[1].(*syscall.WaitStatus)
105104

@@ -123,7 +122,7 @@ func (ex *Exec) Execute(_ context.Context, f *flag.FlagSet, args ...interface{})
123122
// executed. If detach was specified, starts a child in non-detach mode,
124123
// write the child's PID to the pid file. So when the container returns, the
125124
// child process will also return and signal containerd.
126-
if e.Detach {
125+
if ex.detach {
127126
binPath, err := specutils.BinPath()
128127
if err != nil {
129128
Fatalf("error getting bin path: %v", err)

runsc/sandbox/sandbox_test.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ func TestExec(t *testing.T) {
365365
Envv: []string{"PATH=" + os.Getenv("PATH")},
366366
WorkingDirectory: "/",
367367
KUID: uid,
368-
Detach: false,
369368
}
370369

371370
// Verify that "sleep 100" and "sleep 5" are running after exec.
@@ -472,7 +471,6 @@ func TestCapabilities(t *testing.T) {
472471
KUID: uid,
473472
KGID: gid,
474473
Capabilities: &auth.TaskCapabilities{},
475-
Detach: true,
476474
}
477475

478476
// "exe" should fail because we don't have the necessary permissions.
@@ -484,14 +482,10 @@ func TestCapabilities(t *testing.T) {
484482
execArgs.Capabilities = &auth.TaskCapabilities{
485483
EffectiveCaps: auth.CapabilitySetOf(linux.CAP_DAC_OVERRIDE),
486484
}
487-
// First, start running exec.
485+
// "exe" should not fail this time.
488486
if _, err := s.Execute(&execArgs); err != nil {
489487
t.Fatalf("sandbox failed to exec %v: %v", execArgs, err)
490488
}
491-
492-
if err := waitForProcessList(s, expectedPL); err != nil {
493-
t.Error(err)
494-
}
495489
}
496490

497491
// Test that an tty FD is sent over the console socket if one is provided.

0 commit comments

Comments
 (0)