Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid signal: SIGINT process.kill("SIGINT") #92

Open
dong-lufei opened this issue Jan 28, 2023 · 3 comments
Open

Invalid signal: SIGINT process.kill("SIGINT") #92

dong-lufei opened this issue Jan 28, 2023 · 3 comments
Labels
good first issue Good for newcomers runtime

Comments

@dong-lufei
Copy link

https://deno.land/[email protected]/examples/subprocess

I follow the code at the bottom of the document page to execute an invalid type error

import { mergeReadableStreams } from "https://deno.land/[email protected]/streams/merge_readable_streams.ts";

// create the file to attach the process to
const file = await Deno.open("./hello.txt", {
  read: true,
  write: true,
  create: true,
});

// start the process
const process = Deno.run({
  cmd: ["yes"],
  stdout: "piped",
  stderr: "piped",
});

// example of combining stdout and stderr while sending to a file
const joined = mergeReadableStreams(
  process.stdout.readable,
  process.stderr.readable,
);

// returns a promise that resolves when the process is killed/closed
joined.pipeTo(file.writable).then(() => console.log("pipe join done"));

// manually stop process "yes" will never end on its own
setTimeout(() => {
  process.kill("SIGINT"); //Change to SIGTERM, no error
}, 100);

error: Uncaught TypeError: Invalid signal: SIGINT
process.kill("SIGINT"); //SIGTERM
^
at opKill (deno:runtime/js/40_process.js:21:9)
at Process.kill (deno:runtime/js/40_process.js:99:7)
at file:///E:/test/deno/deno01/index.ts:648:11
at Object.action (deno:ext/web/02_timers.js:147:13)
at handleTimerMacrotask (deno:ext/web/02_timers.js:64:12)

@crowlKats crowlKats transferred this issue from denoland/std Jan 28, 2023
@crowlKats
Copy link
Member

The problem is that SIGINT isnt supported on windows currently; the manual should reflect that

@crowlKats crowlKats added the good first issue Good for newcomers label Jan 28, 2023
@dong-lufei
Copy link
Author

This code works fine on windows:

console.log("Press Ctrl-C to trigger a SIGINT signal");

Deno.addSignalListener("SIGINT", () => {
  console.log("interrupted!");
  Deno.exit();
});

// Add a timeout to prevent process exiting immediately.
setTimeout(() => {}, 5000);

@crowlKats
Copy link
Member

to further specify: killing a subprocess is currently not supported on windows.

@kwhinnery kwhinnery transferred this issue from denoland/manual Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers runtime
Projects
None yet
Development

No branches or pull requests

3 participants