carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux
2
3package maintenanceexec
4
5import "os"
6
7type processPipes struct{ inR, inW, outR, outW, contextR, contextW *os.File }
8
9func newPipes() (p *processPipes, err error) {
10 p = &processPipes{}
11 defer func() {
12 if err != nil {
13 p.close()
14 }
15 }()
16 if p.inR, p.inW, err = os.Pipe(); err != nil {
17 return p, err
18 }
19 if p.outR, p.outW, err = os.Pipe(); err != nil {
20 return p, err
21 }
22 if p.contextR, p.contextW, err = os.Pipe(); err != nil {
23 return p, err
24 }
25 return p, nil
26}
27func (p *processPipes) close() {
28 for _, f := range []*os.File{p.inR, p.inW, p.outR, p.outW, p.contextR, p.contextW} {
29 if f != nil {
30 f.Close()
31 }
32 }
33}
34