Follow up to https://github.com/denoland/deno/pull/30029.
Definition of signal numbers/names were moved from `ext/os` to
`ext/signals`.
All occurrences of `tokio::signal` API were replaced with helpers from
`deno_signals` helpers. Additionally clippy lints were added to ensure `tokio::signal`
is not used by accident.
Closes https://github.com/denoland/deno/issues/30223
Co-authored-by: snek <the@snek.dev>
Fixes#16899.
Fixes https://github.com/denoland/deno/issues/23524.
Fixes https://github.com/denoland/deno/issues/23938.
Fixes https://github.com/denoland/deno/issues/27869.
Unblocks #5501.
This PR adds support for additional stdio pipes to windows, as well as
the detached option in `node:child_process`. I also ported over the
`kill` implementation for windows, which means we now can support
`kill(0)` as well as some other signals.
This means that playwright will now work on windows.
Now that we have a way to support detached processes on all platforms,
we can also easily add a `detached` option to `Deno.Command`, similar to
`child_process.spawn`.
---
The reason for moving away from `std::process::Command` is that the
standard library doesn't expose what we need to control the file
descriptor table of child processes on windows. The implementation here
is based off of parts of `std` and parts of `libuv`, and allows us to
support passing extra pipes in addition to detached processes on
windows.
The rust standard library has a fast path for process spawning, where it
will use `posix_spawn` instead of `fork` + `exec`. In order to take that
fast path, you can't have a `pre_exec` hook and you have to pass an
absolute path for the program path.
We were already resolving the program path, but we were unconditionally
doing a `pre_exec` hook. This PR makes the `pre_exec` hook conditional,
which lets us take the fast path in most cases.
**Results**
on an m3 max
canary:
```
took 318755.68ms
```
this PR:
```
took 17184.64ms
```
So an improvement from 318.76 seconds to 17.18 seconds, or about 18.5x
faster
**Benchmark**:
```js
import { fileURLToPath } from "node:url";
const performance = globalThis.performance;
const __filename = fileURLToPath(import.meta.url);
async function spawn() {
const child = new Deno.Command("cat", {
args: [__filename],
stderr: "null",
stdin: "null",
stdout: "null",
}).spawn();
await child.status;
}
async function spawn100() {
const procs = [];
for (let i = 0; i < 100; i++) {
procs.push(spawn());
}
await Promise.all(procs);
}
const start = performance.now();
for (let i = 0; i < 1000; i++) {
console.log(`on ${(i + 1) * 100}`);
await spawn100();
}
const end = performance.now();
console.log(`took ${end - start}ms`);
```
Since `rust 1.87.0` reported `undefined symbol:
ring::pbkdf2::PBKDF2_HMAC_SHA1::*` in CI and it was difficult to debug
locally, use `rust 1.86.0` in CI tests for troubleshoot the errors