Fix check for valid parent id.

Parse as decimal (which means you can't specify --parent-pid in hex,
that's fine). And convert back to string to check that the whole string
was parsed as an int (i.e. "123foobar" should not be converted to
"123").

Thanks Slava and Avital.
This commit is contained in:
Emily Stark
2014-09-26 14:23:57 -07:00
parent 6041122944
commit a8d77fb91a

View File

@@ -69,8 +69,8 @@ var initKeepalive = function () {
// takes the parent process's place before the child process dies.
var startCheckForLiveParent = function (parentPid) {
if (parentPid) {
// Check that we have a pid that looks like an integer.
if (+parseInt(parentPid) !== parentPid) {
// Check that we have a pid that looks like a decimal integer.
if ("" + parseInt(parentPid, 10) !== parentPid) {
console.error("--parent-pid must be a valid process ID.");
process.exit(1);
}