Use is-reachable to detect child process health in self-test.

On Linux, child processes that have exited may remain as <defunct>
"zombie" processes, which prevents process.kill(childPid, 0) from
throwing, so we need a different trick for detecting whether the child
process is still alive.
This commit is contained in:
Ben Newman
2019-05-02 17:07:58 -04:00
parent 4b0e4f8b0d
commit 35ca6980dc
2 changed files with 7 additions and 8 deletions

View File

@@ -41,6 +41,7 @@ var packageJson = {
sqlite3: "3.1.8",
netroute: "1.0.2",
"http-proxy": "1.16.2",
"is-reachable": "3.1.0",
"wordwrap": "0.0.2",
"moment": "2.20.1",
"rimraf": "2.6.2",

View File

@@ -7,6 +7,7 @@ var _ = require('underscore');
var files = require('../fs/files.js');
var catalog = require('../packaging/catalog/catalog.js');
var os = require('os');
var isReachable = require("is-reachable");
var DEFAULT_RELEASE_TRACK = catalog.DEFAULT_TRACK;
@@ -377,6 +378,10 @@ selftest.define("run and SIGKILL parent process", ["yet-unsolved-windows-failure
}
childPid = match[1];
if (!isReachable("localhost:3000").await()) {
selftest.fail("Child process " + childPid + " already dead?");
}
process.kill(run.proc.pid, "SIGKILL");
// This sleep should be a little more time than the interval at which
// the child checks if the parent is still alive, in
@@ -386,14 +391,7 @@ selftest.define("run and SIGKILL parent process", ["yet-unsolved-windows-failure
// Send the child process a signal of 0. If there is no error, it
// means that the process is still running, which is not what we
// expect.
var caughtError;
try {
process.kill(childPid, 0);
} catch (err) {
caughtError = err;
}
if (! caughtError) {
if (isReachable("localhost:3000").await()) {
selftest.fail("Child process " + childPid + " is still running");
}