diff options
| author | Ophestra Umiker <cat@ophivana.moe> | 2024-12-06 16:05:04 +0900 |
|---|---|---|
| committer | Ophestra Umiker <cat@ophivana.moe> | 2024-12-06 16:05:04 +0900 |
| commit | cc816a1aaa34946456c0a10ec6f001f865bc69f9 (patch) | |
| tree | fd94abb9ff5fee7cf24ea82a4558ff6dd82ea443 /helper/pipe.go | |
| parent | b3ef53b193bdf764d8f04e19ea47901b71eec10b (diff) | |
proc: cleaner extra files
Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
Diffstat (limited to 'helper/pipe.go')
| -rw-r--r-- | helper/pipe.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/helper/pipe.go b/helper/pipe.go index e6013283..2a55305a 100644 --- a/helper/pipe.go +++ b/helper/pipe.go @@ -5,6 +5,8 @@ import ( "io" "os" "os/exec" + + "git.ophivana.moe/security/fortify/internal/proc" ) type pipes struct { @@ -47,24 +49,21 @@ func (p *pipes) pipe() error { } // calls pipe to create pipes and sets them up as ExtraFiles, returning their fd -func (p *pipes) prepareCmd(cmd *exec.Cmd) (int, int, error) { - if err := p.pipe(); err != nil { - return -1, -1, err +func (p *pipes) prepareCmd(cmd *exec.Cmd) (argsFd, statFd int, err error) { + argsFd, statFd = -1, -1 + if err = p.pipe(); err != nil { + return } // save a reference of cmd for future use p.cmd = cmd - // ExtraFiles: If non-nil, entry i becomes file descriptor 3+i. - argsFd := 3 + len(cmd.ExtraFiles) - cmd.ExtraFiles = append(cmd.ExtraFiles, p.argsP[0]) - + argsFd = int(proc.ExtraFile(cmd, p.argsP[0])) if p.ready != nil { - cmd.ExtraFiles = append(cmd.ExtraFiles, p.statP[1]) - return argsFd, argsFd + 1, nil - } else { - return argsFd, -1, nil + statFd = int(proc.ExtraFile(cmd, p.statP[1])) } + + return } func (p *pipes) readyWriteArgs() error { |
