Skip to content

Commit e31af1d

Browse files
authored
Merge pull request #1532 from criblio/fix/run-attach-subproc
run attach as subprocess
2 parents 950d3e6 + 9fe4040 commit e31af1d

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

cli/cmd/detach.go

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ scope detach --all --rootdir /path/to/host/mount/proc/<hostpid>/root`,
3131
if len(args) != 0 {
3232
helpErrAndExit(cmd, "--all flag is mutual exclusive with PID or <process_name>")
3333
}
34-
rc.Subprocess = true
3534
return rc.DetachAll(true)
3635
}
3736
if len(args) == 0 {

cli/run/attach.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,8 @@ func (rc *Config) Attach(args []string) (int, error) {
108108
}
109109

110110
ld := loader.New()
111-
if !rc.Subprocess {
112-
err = ld.Attach(args, env)
113-
} else {
114-
_, err = ld.AttachSubProc(args, env)
115-
}
111+
stdoutStderr, err := ld.AttachSubProc(args, env)
112+
util.Warn(stdoutStderr)
116113
if err != nil {
117114
return pid, err
118115
}
@@ -230,13 +227,13 @@ func (rc *Config) detach(pid int) error {
230227

231228
env := os.Environ()
232229
ld := loader.New()
233-
if !rc.Subprocess {
234-
return ld.Detach(args, env)
230+
stdoutStderr, err := ld.DetachSubProc(args, env)
231+
util.Warn(stdoutStderr)
232+
if err != nil {
233+
return err
235234
}
236-
out, err := ld.DetachSubProc(args, env)
237-
util.Warn(out)
238235

239-
return err
236+
return nil
240237
}
241238

242239
// HandleInputArg handles the input argument (process id/name)

0 commit comments

Comments
 (0)