diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-03-15 00:27:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-03-15 00:27:44 +0900 |
| commit | f443d315ad60d761c06135569abb0adb183ac8c1 (patch) | |
| tree | e22b866dc239cd888ef7f3d2ffadaf6a14bd51aa /dbus | |
| parent | 9e18d1de77b2c9bb24a51c2e99b060c6d06818ee (diff) | |
helper: clean up interface
The helper interface was messy due to odd context acquisition order. That has changed, so this cleans it up.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'dbus')
| -rw-r--r-- | dbus/run.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/dbus/run.go b/dbus/run.go index fc3943a5..ae2d9e08 100644 --- a/dbus/run.go +++ b/dbus/run.go @@ -39,9 +39,14 @@ func (p *Proxy) Start(ctx context.Context, output io.Writer, sandbox bool) error c, cancel := context.WithCancelCause(ctx) if !sandbox { - h = helper.New(c, p.seal, p.name, argF) - // xdg-dbus-proxy does not need to inherit the environment - h.SetEnv(make([]string, 0)) + h = helper.NewDirect(c, p.seal, p.name, argF, func(cmd *exec.Cmd) { + if output != nil { + cmd.Stdout, cmd.Stderr = output, output + } + + // xdg-dbus-proxy does not need to inherit the environment + cmd.Env = make([]string, 0) + }, true) } else { // look up absolute path if name is just a file name toolPath := p.name @@ -111,14 +116,15 @@ func (p *Proxy) Start(ctx context.Context, output io.Writer, sandbox bool) error bc.Bind(k, k) } - h = helper.MustNewBwrap(c, bc, toolPath, true, p.seal, argF, nil, nil) + h = helper.MustNewBwrap(c, bc, toolPath, true, p.seal, argF, func(cmd *exec.Cmd) { + if output != nil { + cmd.Stdout, cmd.Stderr = output, output + } + }, nil, nil, true) p.bwrap = bc } - if output != nil { - h.SetStdout(output).SetStderr(output) - } - if err := h.Start(true); err != nil { + if err := h.Start(); err != nil { cancel(err) return err } |
