Skip to content

ChildProcess.kill() does not indicate failure when process has already exited #33206

@kevgeoleo

Description

@kevgeoleo

Version: Deno 2.7.11

Hi,

I would like to report a behavior in Deno that can be reproduced using the below snippet

import { spawn } from 'node:child_process';

const proc = spawn('echo', ['hi'], {
  stdio: 'inherit'
});

// Wait for the process to exit so it is no longer running
await new Promise((resolve, reject) => {
  proc.on('error', reject);
  proc.on('close', (code, signal) => {
    resolve({ code, signal });
  });
});

// Now attempt to send a signal to the already-exited process
try {
  const killed = proc.kill('SIGQUIT');
  if (!killed) {
    throw new Error('Failed to send SIGQUIT: process may have already exited');
  }
} catch (err) {
  // Normal, catchable JavaScript error
  console.error('Caught error when killing process:', err);
}

Expected behavior

root@KContainer:~/7362# node simple.mjs
hi
Caught error when killing process: Error: Failed to send SIGQUIT: process may have already exited
    at file:///home/c01kele/git/run/cerebras/deno/OPENAI/gpt5.1/filter/batch_2/cross_runtime/temp_node/7362/simple.mjs:23:11
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

Actual behavior

root@KContainer:~/7362# deno run -A simple.mjs
hi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions