MCPcopy
hub / github.com/cloudflare/tableflip / childProcess

Function childProcess

upgrader_test.go:93–144  ·  view source on GitHub ↗

Used by Benchmark and TestUpgraderOnOS

(upg *Upgrader)

Source from the content-addressed store, hash-verified

91
92// Used by Benchmark and TestUpgraderOnOS
93func childProcess(upg *Upgrader) error {
94 if !upg.HasParent() {
95 return errors.New("Upgrader doesn't recognize parent")
96 }
97
98 wState, err := upg.Fds.File("wState")
99 if err != nil {
100 return err
101 }
102 if wState != nil {
103 state := &childState{
104 PID: os.Getpid(),
105 }
106 if err := gob.NewEncoder(wState).Encode(state); err != nil {
107 return err
108 }
109 wState.Close()
110 }
111
112 for _, name := range names {
113 file, err := upg.Fds.File(name)
114 if err != nil {
115 return fmt.Errorf("can't get file %s: %s", name, err)
116 }
117 if file == nil {
118 continue
119 }
120 if _, err := io.WriteString(file, name); err != nil {
121 return fmt.Errorf("can't write to %s: %s", name, err)
122 }
123 file.Close()
124 }
125
126 rExit, err := upg.Fds.File("rExit")
127 if err != nil {
128 return err
129 }
130
131 // Ready closes all inherited but unused files.
132 if err := upg.Ready(); err != nil {
133 return fmt.Errorf("can't signal ready: %s", err)
134 }
135
136 // Block until the parent is done with us. Returning an
137 // error here won't make the parent fail, so don't bother.
138 if rExit != nil {
139 var b [1]byte
140 rExit.Read(b[:])
141 }
142
143 return nil
144}
145
146func TestUpgraderOnOS(t *testing.T) {
147 u, err := newUpgrader(stdEnv, Options{})

Callers 1

TestMainFunction · 0.85

Calls 3

ReadyMethod · 0.65
HasParentMethod · 0.45
FileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…