#Bun.spawn process kill method not working?

1 messages · Page 1 of 1 (latest)

zinc arch
#

I kill a spawned process with deployedProcesses[repo].kill();, then wait for it to exit with await deployedProcesses[repo].exited;

When I run this after:

console.log(
  "Killed?",
  deployedProcesses[repo].exitCode,
  deployedProcesses[repo].killed
);

It logs Killed? null true
According to the typings:

#

I verified the process is in fact still running, since it has a web server on it.

#

I even tried this to kill it, and no dice:

const killProcess = Bun.spawn({
  cmd: ["kill", "-9", deployedProcesses[repo].pid],
  stdout: "inherit",
  stderr: "inherit",
  env: {
    ...process.env,
  },
});
await killProcess.exited;
#

The same command works perfectly fine, running it in a regular bash session.

#

Something interesting to note, and perhaps related:

#

The process id, from the spawned process, does not match what lsof returns

#

Oh, this is interesting. That process is being started with npm start. When I change the command to node index.js, it shows the matching process id.

#

I suppose that's since npm start spawns a sub process, and killing the npm start process does not kill the sub process?