| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7eb6930 commit 963d7d7
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,9 @@ | |||
| 19 | 19 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
| 20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. | |
| 21 | 21 | ||
| 22 | + // This tests that a socket sent to the forked process works. | ||
| 23 | + // See https://github.com/nodejs/node/commit/dceebbfa | ||
| 24 | + | ||
| 22 | 25 | 'use strict'; | |
| 23 | 26 | const { | |
| 24 | 27 | mustCall, | |
@@ -65,7 +68,7 @@ if (process.argv[2] === 'child') { | |||
| 65 | 68 | socket.on('finish', mustCall(() => { | |
| 66 | 69 | debug(`[${id}] socket finished ${m}`); | |
| 67 | 70 | })); | |
| 68 | - })); | ||
| 71 | + }, 4)); | ||
| 69 | 72 | ||
| 70 | 73 | process.on('message', mustCall((m) => { | |
| 71 | 74 | if (m !== 'close') return; | |
@@ -74,7 +77,7 @@ if (process.argv[2] === 'child') { | |||
| 74 | 77 | debug(`[${id}] ending ${i}/${needEnd.length}`); | |
| 75 | 78 | endMe.end('end'); | |
| 76 | 79 | }); | |
| 77 | - })); | ||
| 80 | + }, 4)); | ||
| 78 | 81 | ||
| 79 | 82 | process.on('disconnect', mustCall(() => { | |
| 80 | 83 | debug(`[${id}] process disconnect, ending`); | |
@@ -146,9 +149,22 @@ if (process.argv[2] === 'child') { | |||
| 146 | 149 | server.on('close', mustCall(function() { | |
| 147 | 150 | closeEmitted = true; | |
| 148 | 151 | ||
| 149 | - child1.kill(); | ||
| 150 | - child2.kill(); | ||
| 151 | - child3.kill(); | ||
| 152 | + // Clean up child processes. | ||
| 153 | + try { | ||
| 154 | + child1.kill(); | ||
| 155 | + } catch { | ||
| 156 | + debug('child process already terminated'); | ||
| 157 | + } | ||
| 158 | + try { | ||
| 159 | + child2.kill(); | ||
| 160 | + } catch { | ||
| 161 | + debug('child process already terminated'); | ||
| 162 | + } | ||
| 163 | + try { | ||
| 164 | + child3.kill(); | ||
| 165 | + } catch { | ||
| 166 | + debug('child process already terminated'); | ||
| 167 | + } | ||
| 152 | 168 | })); | |
| 153 | 169 | ||
| 154 | 170 | server.listen(0, '127.0.0.1'); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments