mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
BREAKING(unstable): Remove Deno.Signals enum, Deno.signals.* (#11909)
This commit is contained in:
parent
b7c2902c97
commit
c132c8690b
12 changed files with 187 additions and 380 deletions
|
@ -25,17 +25,14 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
||||||
"EmitOptions",
|
"EmitOptions",
|
||||||
"EmitResult",
|
"EmitResult",
|
||||||
"HttpClient",
|
"HttpClient",
|
||||||
"LinuxSignal",
|
|
||||||
"Location",
|
"Location",
|
||||||
"MXRecord",
|
"MXRecord",
|
||||||
"MacOSSignal",
|
|
||||||
"Metrics",
|
"Metrics",
|
||||||
"OpMetrics",
|
"OpMetrics",
|
||||||
"RecordType",
|
"RecordType",
|
||||||
"ResolveDnsOptions",
|
"ResolveDnsOptions",
|
||||||
"SRVRecord",
|
"SRVRecord",
|
||||||
"SetRawOptions",
|
"SetRawOptions",
|
||||||
"Signal",
|
|
||||||
"SignalStream",
|
"SignalStream",
|
||||||
"StartTlsOptions",
|
"StartTlsOptions",
|
||||||
"SystemMemoryInfo",
|
"SystemMemoryInfo",
|
||||||
|
|
5
cli/dts/lib.deno.ns.d.ts
vendored
5
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -1982,13 +1982,12 @@ declare namespace Deno {
|
||||||
stderrOutput(): Promise<Uint8Array>;
|
stderrOutput(): Promise<Uint8Array>;
|
||||||
close(): void;
|
close(): void;
|
||||||
|
|
||||||
/** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
|
/** **UNSTABLE**
|
||||||
* enum.
|
|
||||||
*
|
*
|
||||||
* Send a signal to process. This functionality currently only works on
|
* Send a signal to process. This functionality currently only works on
|
||||||
* Linux and Mac OS.
|
* Linux and Mac OS.
|
||||||
*/
|
*/
|
||||||
kill(signo: number): void;
|
kill(signo: string): void; // TODO(ry): Use Signal type here once made stable.
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ProcessStatus =
|
export type ProcessStatus =
|
||||||
|
|
174
cli/dts/lib.deno.unstable.d.ts
vendored
174
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -562,77 +562,40 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function applySourceMap(location: Location): Location;
|
export function applySourceMap(location: Location): Location;
|
||||||
|
|
||||||
enum LinuxSignal {
|
export type Signal =
|
||||||
SIGHUP = 1,
|
| "SIGABRT"
|
||||||
SIGINT = 2,
|
| "SIGALRM"
|
||||||
SIGQUIT = 3,
|
| "SIGBUS"
|
||||||
SIGILL = 4,
|
| "SIGCHLD"
|
||||||
SIGTRAP = 5,
|
| "SIGCONT"
|
||||||
SIGABRT = 6,
|
| "SIGEMT"
|
||||||
SIGBUS = 7,
|
| "SIGFPE"
|
||||||
SIGFPE = 8,
|
| "SIGHUP"
|
||||||
SIGKILL = 9,
|
| "SIGILL"
|
||||||
SIGUSR1 = 10,
|
| "SIGINFO"
|
||||||
SIGSEGV = 11,
|
| "SIGINT"
|
||||||
SIGUSR2 = 12,
|
| "SIGIO"
|
||||||
SIGPIPE = 13,
|
| "SIGKILL"
|
||||||
SIGALRM = 14,
|
| "SIGPIPE"
|
||||||
SIGTERM = 15,
|
| "SIGPROF"
|
||||||
SIGSTKFLT = 16,
|
| "SIGPWR"
|
||||||
SIGCHLD = 17,
|
| "SIGQUIT"
|
||||||
SIGCONT = 18,
|
| "SIGSEGV"
|
||||||
SIGSTOP = 19,
|
| "SIGSTKFLT"
|
||||||
SIGTSTP = 20,
|
| "SIGSTOP"
|
||||||
SIGTTIN = 21,
|
| "SIGSYS"
|
||||||
SIGTTOU = 22,
|
| "SIGTERM"
|
||||||
SIGURG = 23,
|
| "SIGTRAP"
|
||||||
SIGXCPU = 24,
|
| "SIGTSTP"
|
||||||
SIGXFSZ = 25,
|
| "SIGTTIN"
|
||||||
SIGVTALRM = 26,
|
| "SIGTTOU"
|
||||||
SIGPROF = 27,
|
| "SIGURG"
|
||||||
SIGWINCH = 28,
|
| "SIGUSR1"
|
||||||
SIGIO = 29,
|
| "SIGUSR2"
|
||||||
SIGPWR = 30,
|
| "SIGVTALRM"
|
||||||
SIGSYS = 31,
|
| "SIGWINCH"
|
||||||
}
|
| "SIGXCPU"
|
||||||
enum MacOSSignal {
|
| "SIGXFSZ";
|
||||||
SIGHUP = 1,
|
|
||||||
SIGINT = 2,
|
|
||||||
SIGQUIT = 3,
|
|
||||||
SIGILL = 4,
|
|
||||||
SIGTRAP = 5,
|
|
||||||
SIGABRT = 6,
|
|
||||||
SIGEMT = 7,
|
|
||||||
SIGFPE = 8,
|
|
||||||
SIGKILL = 9,
|
|
||||||
SIGBUS = 10,
|
|
||||||
SIGSEGV = 11,
|
|
||||||
SIGSYS = 12,
|
|
||||||
SIGPIPE = 13,
|
|
||||||
SIGALRM = 14,
|
|
||||||
SIGTERM = 15,
|
|
||||||
SIGURG = 16,
|
|
||||||
SIGSTOP = 17,
|
|
||||||
SIGTSTP = 18,
|
|
||||||
SIGCONT = 19,
|
|
||||||
SIGCHLD = 20,
|
|
||||||
SIGTTIN = 21,
|
|
||||||
SIGTTOU = 22,
|
|
||||||
SIGIO = 23,
|
|
||||||
SIGXCPU = 24,
|
|
||||||
SIGXFSZ = 25,
|
|
||||||
SIGVTALRM = 26,
|
|
||||||
SIGPROF = 27,
|
|
||||||
SIGWINCH = 28,
|
|
||||||
SIGINFO = 29,
|
|
||||||
SIGUSR1 = 30,
|
|
||||||
SIGUSR2 = 31,
|
|
||||||
}
|
|
||||||
|
|
||||||
/** **UNSTABLE**: Further changes required to make platform independent.
|
|
||||||
*
|
|
||||||
* Signals numbers. This is platform dependent. */
|
|
||||||
export const Signal: typeof MacOSSignal | typeof LinuxSignal;
|
|
||||||
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted.
|
/** **UNSTABLE**: new API, yet to be vetted.
|
||||||
*
|
*
|
||||||
|
@ -640,7 +603,7 @@ declare namespace Deno {
|
||||||
* `PromiseLike`. */
|
* `PromiseLike`. */
|
||||||
export class SignalStream
|
export class SignalStream
|
||||||
implements AsyncIterableIterator<void>, PromiseLike<void> {
|
implements AsyncIterableIterator<void>, PromiseLike<void> {
|
||||||
constructor(signal: typeof Deno.Signal);
|
constructor(signal: Signal);
|
||||||
then<T, S>(
|
then<T, S>(
|
||||||
f: (v: void) => T | Promise<T>,
|
f: (v: void) => T | Promise<T>,
|
||||||
g?: (v: void) => S | Promise<S>,
|
g?: (v: void) => S | Promise<S>,
|
||||||
|
@ -656,7 +619,7 @@ declare namespace Deno {
|
||||||
* iterator.
|
* iterator.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* for await (const _ of Deno.signal(Deno.Signal.SIGTERM)) {
|
* for await (const _ of Deno.signal("SIGTERM")) {
|
||||||
* console.log("got SIGTERM!");
|
* console.log("got SIGTERM!");
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
@ -665,7 +628,7 @@ declare namespace Deno {
|
||||||
* first one.
|
* first one.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* await Deno.signal(Deno.Signal.SIGTERM);
|
* await Deno.signal("SIGTERM");
|
||||||
* console.log("SIGTERM received!")
|
* console.log("SIGTERM received!")
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
@ -673,7 +636,7 @@ declare namespace Deno {
|
||||||
* of the signal stream object.
|
* of the signal stream object.
|
||||||
*
|
*
|
||||||
* ```ts
|
* ```ts
|
||||||
* const sig = Deno.signal(Deno.Signal.SIGTERM);
|
* const sig = Deno.signal("SIGTERM");
|
||||||
* setTimeout(() => { sig.dispose(); }, 5000);
|
* setTimeout(() => { sig.dispose(); }, 5000);
|
||||||
* for await (const _ of sig) {
|
* for await (const _ of sig) {
|
||||||
* console.log("SIGTERM!")
|
* console.log("SIGTERM!")
|
||||||
|
@ -685,55 +648,7 @@ declare namespace Deno {
|
||||||
*
|
*
|
||||||
* NOTE: This functionality is not yet implemented on Windows.
|
* NOTE: This functionality is not yet implemented on Windows.
|
||||||
*/
|
*/
|
||||||
export function signal(signo: number): SignalStream;
|
export function signal(sig: Signal): SignalStream;
|
||||||
|
|
||||||
/** **UNSTABLE**: new API, yet to be vetted. */
|
|
||||||
export const signals: {
|
|
||||||
/** Returns the stream of SIGALRM signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGALRM)`. */
|
|
||||||
alarm: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGCHLD signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGCHLD)`. */
|
|
||||||
child: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGHUP signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGHUP)`. */
|
|
||||||
hungup: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGINT signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGINT)`. */
|
|
||||||
interrupt: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGIO signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGIO)`. */
|
|
||||||
io: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGPIPE signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGPIPE)`. */
|
|
||||||
pipe: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGQUIT signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGQUIT)`. */
|
|
||||||
quit: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGTERM signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGTERM)`. */
|
|
||||||
terminate: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGUSR1 signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR1)`. */
|
|
||||||
userDefined1: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGUSR2 signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGUSR2)`. */
|
|
||||||
userDefined2: () => SignalStream;
|
|
||||||
/** Returns the stream of SIGWINCH signals.
|
|
||||||
*
|
|
||||||
* This method is the shorthand for `Deno.signal(Deno.Signal.SIGWINCH)`. */
|
|
||||||
windowChange: () => SignalStream;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type SetRawOptions = {
|
export type SetRawOptions = {
|
||||||
cbreak: boolean;
|
cbreak: boolean;
|
||||||
|
@ -803,11 +718,8 @@ declare namespace Deno {
|
||||||
},
|
},
|
||||||
>(opt: T): Process<T>;
|
>(opt: T): Process<T>;
|
||||||
|
|
||||||
/** **UNSTABLE**: The `signo` argument may change to require the Deno.Signal
|
/** **UNSTABLE**: Send a signal to process under given `pid`. This
|
||||||
* enum.
|
* functionality only works on Linux and Mac OS.
|
||||||
*
|
|
||||||
* Send a signal to process under given `pid`. This functionality currently
|
|
||||||
* only works on Linux and Mac OS.
|
|
||||||
*
|
*
|
||||||
* If `pid` is negative, the signal will be sent to the process group
|
* If `pid` is negative, the signal will be sent to the process group
|
||||||
* identified by `pid`.
|
* identified by `pid`.
|
||||||
|
@ -816,10 +728,10 @@ declare namespace Deno {
|
||||||
* cmd: ["sleep", "10000"]
|
* cmd: ["sleep", "10000"]
|
||||||
* });
|
* });
|
||||||
*
|
*
|
||||||
* Deno.kill(p.pid, Deno.Signal.SIGINT);
|
* Deno.kill(p.pid, "SIGINT");
|
||||||
*
|
*
|
||||||
* Requires `allow-run` permission. */
|
* Requires `allow-run` permission. */
|
||||||
export function kill(pid: number, signo: number): void;
|
export function kill(pid: number, signo: Signal): void;
|
||||||
|
|
||||||
/** **UNSTABLE**: New API, yet to be vetted. Additional consideration is still
|
/** **UNSTABLE**: New API, yet to be vetted. Additional consideration is still
|
||||||
* necessary around the permissions required.
|
* necessary around the permissions required.
|
||||||
|
|
2
cli/tests/testdata/raw_mode_cbreak.ts
vendored
2
cli/tests/testdata/raw_mode_cbreak.ts
vendored
|
@ -1,7 +1,7 @@
|
||||||
Deno.setRaw(0, true);
|
Deno.setRaw(0, true);
|
||||||
Deno.setRaw(0, true, { cbreak: true }); // Can be called multiple times
|
Deno.setRaw(0, true, { cbreak: true }); // Can be called multiple times
|
||||||
|
|
||||||
const signal = Deno.signals.interrupt();
|
const signal = Deno.signal("SIGINT");
|
||||||
|
|
||||||
Deno.stdout.writeSync(new TextEncoder().encode("S"));
|
Deno.stdout.writeSync(new TextEncoder().encode("S"));
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,12 @@ unitTest(
|
||||||
},
|
},
|
||||||
async function runCommandFailedWithSignal() {
|
async function runCommandFailedWithSignal() {
|
||||||
const p = Deno.run({
|
const p = Deno.run({
|
||||||
cmd: [Deno.execPath(), "eval", "--unstable", "Deno.kill(Deno.pid, 9)"],
|
cmd: [
|
||||||
|
Deno.execPath(),
|
||||||
|
"eval",
|
||||||
|
"--unstable",
|
||||||
|
"Deno.kill(Deno.pid, 'SIGKILL')",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
const status = await p.status();
|
const status = await p.status();
|
||||||
assertEquals(status.success, false);
|
assertEquals(status.success, false);
|
||||||
|
@ -436,7 +441,7 @@ unitTest(
|
||||||
|
|
||||||
let error = null;
|
let error = null;
|
||||||
try {
|
try {
|
||||||
p.kill(Deno.Signal.SIGTERM);
|
p.kill("SIGTERM");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error = e;
|
error = e;
|
||||||
}
|
}
|
||||||
|
@ -454,21 +459,13 @@ unitTest(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unitTest(function signalNumbers() {
|
|
||||||
if (Deno.build.os === "darwin") {
|
|
||||||
assertEquals(Deno.Signal.SIGSTOP, 17);
|
|
||||||
} else if (Deno.build.os === "linux") {
|
|
||||||
assertEquals(Deno.Signal.SIGSTOP, 19);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
unitTest(function killPermissions() {
|
unitTest(function killPermissions() {
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
// Unlike the other test cases, we don't have permission to spawn a
|
// Unlike the other test cases, we don't have permission to spawn a
|
||||||
// subprocess we can safely kill. Instead we send SIGCONT to the current
|
// subprocess we can safely kill. Instead we send SIGCONT to the current
|
||||||
// process - assuming that Deno does not have a special handler set for it
|
// process - assuming that Deno does not have a special handler set for it
|
||||||
// and will just continue even if a signal is erroneously sent.
|
// and will just continue even if a signal is erroneously sent.
|
||||||
Deno.kill(Deno.pid, Deno.Signal.SIGCONT);
|
Deno.kill(Deno.pid, "SIGCONT");
|
||||||
}, Deno.errors.PermissionDenied);
|
}, Deno.errors.PermissionDenied);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -479,19 +476,17 @@ unitTest(
|
||||||
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
cmd: [Deno.execPath(), "eval", "setTimeout(() => {}, 10000)"],
|
||||||
});
|
});
|
||||||
|
|
||||||
assertEquals(Deno.Signal.SIGINT, 2);
|
Deno.kill(p.pid, "SIGINT");
|
||||||
Deno.kill(p.pid, Deno.Signal.SIGINT);
|
|
||||||
const status = await p.status();
|
const status = await p.status();
|
||||||
|
|
||||||
assertEquals(status.success, false);
|
assertEquals(status.success, false);
|
||||||
try {
|
try {
|
||||||
assertEquals(status.code, 128 + Deno.Signal.SIGINT);
|
assertEquals(status.signal, "SIGINT");
|
||||||
assertEquals(status.signal, Deno.Signal.SIGINT);
|
|
||||||
} catch {
|
} catch {
|
||||||
// TODO(nayeemrmn): On Windows sometimes the following values are given
|
// TODO(nayeemrmn): On Windows sometimes the following values are given
|
||||||
// instead. Investigate and remove this catch when fixed.
|
// instead. Investigate and remove this catch when fixed.
|
||||||
assertEquals(status.code, 1);
|
assertEquals(status.code, 130);
|
||||||
assertEquals(status.signal, undefined);
|
assertEquals(status.signal, 2);
|
||||||
}
|
}
|
||||||
p.close();
|
p.close();
|
||||||
},
|
},
|
||||||
|
@ -505,7 +500,8 @@ unitTest({ perms: { run: true, read: true } }, function killFailed() {
|
||||||
assert(!p.stdout);
|
assert(!p.stdout);
|
||||||
|
|
||||||
assertThrows(() => {
|
assertThrows(() => {
|
||||||
Deno.kill(p.pid, 12345);
|
// @ts-expect-error testing runtime error of bad signal
|
||||||
|
Deno.kill(p.pid, "foobar");
|
||||||
}, TypeError);
|
}, TypeError);
|
||||||
|
|
||||||
p.close();
|
p.close();
|
||||||
|
|
|
@ -13,84 +13,84 @@ unitTest(
|
||||||
function signalsNotImplemented() {
|
function signalsNotImplemented() {
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signal(1);
|
Deno.signal("SIGINT");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.alarm(); // for SIGALRM
|
Deno.signal("SIGALRM");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.child(); // for SIGCHLD
|
Deno.signal("SIGCHLD");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.hungup(); // for SIGHUP
|
Deno.signal("SIGHUP");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.interrupt(); // for SIGINT
|
Deno.signal("SIGINT");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.io(); // for SIGIO
|
Deno.signal("SIGIO");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.pipe(); // for SIGPIPE
|
Deno.signal("SIGPIPE");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.quit(); // for SIGQUIT
|
Deno.signal("SIGQUIT");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.terminate(); // for SIGTERM
|
Deno.signal("SIGTERM");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.userDefined1(); // for SIGUSR1
|
Deno.signal("SIGUSR1");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.userDefined2(); // for SIGURS2
|
Deno.signal("SIGUSR2");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
);
|
);
|
||||||
assertThrows(
|
assertThrows(
|
||||||
() => {
|
() => {
|
||||||
Deno.signals.windowChange(); // for SIGWINCH
|
Deno.signal("SIGWINCH");
|
||||||
},
|
},
|
||||||
Error,
|
Error,
|
||||||
"not implemented",
|
"not implemented",
|
||||||
|
@ -106,12 +106,12 @@ unitTest(
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
|
||||||
let c = 0;
|
let c = 0;
|
||||||
const sig = Deno.signal(Deno.Signal.SIGUSR1);
|
const sig = Deno.signal("SIGUSR1");
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
await delay(20);
|
await delay(20);
|
||||||
for (const _ of Array(3)) {
|
for (const _ of Array(3)) {
|
||||||
// Sends SIGUSR1 3 times.
|
// Sends SIGUSR1 3 times.
|
||||||
Deno.kill(Deno.pid, Deno.Signal.SIGUSR1);
|
Deno.kill(Deno.pid, "SIGUSR1");
|
||||||
await delay(20);
|
await delay(20);
|
||||||
}
|
}
|
||||||
sig.dispose();
|
sig.dispose();
|
||||||
|
@ -138,7 +138,7 @@ unitTest(
|
||||||
Deno.execPath(),
|
Deno.execPath(),
|
||||||
"eval",
|
"eval",
|
||||||
"--unstable",
|
"--unstable",
|
||||||
"(async () => { for await (const _ of Deno.signals.io()) {} })()",
|
"(async () => { for await (const _ of Deno.signal('SIGIO')) {} })()",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
const res = await p.status();
|
const res = await p.status();
|
||||||
|
@ -154,9 +154,9 @@ unitTest(
|
||||||
// This prevents the program from exiting.
|
// This prevents the program from exiting.
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
|
||||||
const sig = Deno.signal(Deno.Signal.SIGUSR1);
|
const sig = Deno.signal("SIGUSR1");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Deno.kill(Deno.pid, Deno.Signal.SIGUSR1);
|
Deno.kill(Deno.pid, "SIGUSR1");
|
||||||
resolvable.resolve();
|
resolvable.resolve();
|
||||||
}, 20);
|
}, 20);
|
||||||
await sig;
|
await sig;
|
||||||
|
@ -176,7 +176,7 @@ unitTest(
|
||||||
const t = setInterval(() => {}, 1000);
|
const t = setInterval(() => {}, 1000);
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
const sig = Deno.signal(Deno.Signal.SIGUSR1);
|
const sig = Deno.signal("SIGUSR1");
|
||||||
sig.then(() => {
|
sig.then(() => {
|
||||||
called = true;
|
called = true;
|
||||||
});
|
});
|
||||||
|
@ -200,37 +200,37 @@ unitTest(
|
||||||
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
{ ignore: Deno.build.os === "windows", perms: { run: true } },
|
||||||
function signalShorthandsTest() {
|
function signalShorthandsTest() {
|
||||||
let s: Deno.SignalStream;
|
let s: Deno.SignalStream;
|
||||||
s = Deno.signals.alarm(); // for SIGALRM
|
s = Deno.signal("SIGALRM");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.child(); // for SIGCHLD
|
s = Deno.signal("SIGCHLD");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.hungup(); // for SIGHUP
|
s = Deno.signal("SIGHUP");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.interrupt(); // for SIGINT
|
s = Deno.signal("SIGINT");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.io(); // for SIGIO
|
s = Deno.signal("SIGIO");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.pipe(); // for SIGPIPE
|
s = Deno.signal("SIGPIPE");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.quit(); // for SIGQUIT
|
s = Deno.signal("SIGQUIT");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.terminate(); // for SIGTERM
|
s = Deno.signal("SIGTERM");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.userDefined1(); // for SIGUSR1
|
s = Deno.signal("SIGUSR1");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.userDefined2(); // for SIGURS2
|
s = Deno.signal("SIGUSR2");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
s = Deno.signals.windowChange(); // for SIGWINCH
|
s = Deno.signal("SIGWINCH");
|
||||||
assert(s instanceof Deno.SignalStream);
|
assert(s instanceof Deno.SignalStream);
|
||||||
s.dispose();
|
s.dispose();
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
const { errors } = window.__bootstrap.errors;
|
const { errors } = window.__bootstrap.errors;
|
||||||
const {
|
const {
|
||||||
Error,
|
Error,
|
||||||
ObjectAssign,
|
|
||||||
Promise,
|
Promise,
|
||||||
PromisePrototypeThen,
|
PromisePrototypeThen,
|
||||||
PromiseResolve,
|
PromiseResolve,
|
||||||
|
@ -26,148 +25,6 @@
|
||||||
core.opSync("op_signal_unbind", rid);
|
core.opSync("op_signal_unbind", rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
// From `kill -l`
|
|
||||||
const LinuxSignal = {
|
|
||||||
1: "SIGHUP",
|
|
||||||
2: "SIGINT",
|
|
||||||
3: "SIGQUIT",
|
|
||||||
4: "SIGILL",
|
|
||||||
5: "SIGTRAP",
|
|
||||||
6: "SIGABRT",
|
|
||||||
7: "SIGBUS",
|
|
||||||
8: "SIGFPE",
|
|
||||||
9: "SIGKILL",
|
|
||||||
10: "SIGUSR1",
|
|
||||||
11: "SIGSEGV",
|
|
||||||
12: "SIGUSR2",
|
|
||||||
13: "SIGPIPE",
|
|
||||||
14: "SIGALRM",
|
|
||||||
15: "SIGTERM",
|
|
||||||
16: "SIGSTKFLT",
|
|
||||||
17: "SIGCHLD",
|
|
||||||
18: "SIGCONT",
|
|
||||||
19: "SIGSTOP",
|
|
||||||
20: "SIGTSTP",
|
|
||||||
21: "SIGTTIN",
|
|
||||||
22: "SIGTTOU",
|
|
||||||
23: "SIGURG",
|
|
||||||
24: "SIGXCPU",
|
|
||||||
25: "SIGXFSZ",
|
|
||||||
26: "SIGVTALRM",
|
|
||||||
27: "SIGPROF",
|
|
||||||
28: "SIGWINCH",
|
|
||||||
29: "SIGIO",
|
|
||||||
30: "SIGPWR",
|
|
||||||
31: "SIGSYS",
|
|
||||||
SIGHUP: 1,
|
|
||||||
SIGINT: 2,
|
|
||||||
SIGQUIT: 3,
|
|
||||||
SIGILL: 4,
|
|
||||||
SIGTRAP: 5,
|
|
||||||
SIGABRT: 6,
|
|
||||||
SIGBUS: 7,
|
|
||||||
SIGFPE: 8,
|
|
||||||
SIGKILL: 9,
|
|
||||||
SIGUSR1: 10,
|
|
||||||
SIGSEGV: 11,
|
|
||||||
SIGUSR2: 12,
|
|
||||||
SIGPIPE: 13,
|
|
||||||
SIGALRM: 14,
|
|
||||||
SIGTERM: 15,
|
|
||||||
SIGSTKFLT: 16,
|
|
||||||
SIGCHLD: 17,
|
|
||||||
SIGCONT: 18,
|
|
||||||
SIGSTOP: 19,
|
|
||||||
SIGTSTP: 20,
|
|
||||||
SIGTTIN: 21,
|
|
||||||
SIGTTOU: 22,
|
|
||||||
SIGURG: 23,
|
|
||||||
SIGXCPU: 24,
|
|
||||||
SIGXFSZ: 25,
|
|
||||||
SIGVTALRM: 26,
|
|
||||||
SIGPROF: 27,
|
|
||||||
SIGWINCH: 28,
|
|
||||||
SIGIO: 29,
|
|
||||||
SIGPWR: 30,
|
|
||||||
SIGSYS: 31,
|
|
||||||
};
|
|
||||||
|
|
||||||
// From `kill -l`
|
|
||||||
const MacOSSignal = {
|
|
||||||
1: "SIGHUP",
|
|
||||||
2: "SIGINT",
|
|
||||||
3: "SIGQUIT",
|
|
||||||
4: "SIGILL",
|
|
||||||
5: "SIGTRAP",
|
|
||||||
6: "SIGABRT",
|
|
||||||
7: "SIGEMT",
|
|
||||||
8: "SIGFPE",
|
|
||||||
9: "SIGKILL",
|
|
||||||
10: "SIGBUS",
|
|
||||||
11: "SIGSEGV",
|
|
||||||
12: "SIGSYS",
|
|
||||||
13: "SIGPIPE",
|
|
||||||
14: "SIGALRM",
|
|
||||||
15: "SIGTERM",
|
|
||||||
16: "SIGURG",
|
|
||||||
17: "SIGSTOP",
|
|
||||||
18: "SIGTSTP",
|
|
||||||
19: "SIGCONT",
|
|
||||||
20: "SIGCHLD",
|
|
||||||
21: "SIGTTIN",
|
|
||||||
22: "SIGTTOU",
|
|
||||||
23: "SIGIO",
|
|
||||||
24: "SIGXCPU",
|
|
||||||
25: "SIGXFSZ",
|
|
||||||
26: "SIGVTALRM",
|
|
||||||
27: "SIGPROF",
|
|
||||||
28: "SIGWINCH",
|
|
||||||
29: "SIGINFO",
|
|
||||||
30: "SIGUSR1",
|
|
||||||
31: "SIGUSR2",
|
|
||||||
SIGHUP: 1,
|
|
||||||
SIGINT: 2,
|
|
||||||
SIGQUIT: 3,
|
|
||||||
SIGILL: 4,
|
|
||||||
SIGTRAP: 5,
|
|
||||||
SIGABRT: 6,
|
|
||||||
SIGEMT: 7,
|
|
||||||
SIGFPE: 8,
|
|
||||||
SIGKILL: 9,
|
|
||||||
SIGBUS: 10,
|
|
||||||
SIGSEGV: 11,
|
|
||||||
SIGSYS: 12,
|
|
||||||
SIGPIPE: 13,
|
|
||||||
SIGALRM: 14,
|
|
||||||
SIGTERM: 15,
|
|
||||||
SIGURG: 16,
|
|
||||||
SIGSTOP: 17,
|
|
||||||
SIGTSTP: 18,
|
|
||||||
SIGCONT: 19,
|
|
||||||
SIGCHLD: 20,
|
|
||||||
SIGTTIN: 21,
|
|
||||||
SIGTTOU: 22,
|
|
||||||
SIGIO: 23,
|
|
||||||
SIGXCPU: 24,
|
|
||||||
SIGXFSZ: 25,
|
|
||||||
SIGVTALRM: 26,
|
|
||||||
SIGPROF: 27,
|
|
||||||
SIGWINCH: 28,
|
|
||||||
SIGINFO: 29,
|
|
||||||
SIGUSR1: 30,
|
|
||||||
SIGUSR2: 31,
|
|
||||||
};
|
|
||||||
|
|
||||||
const Signal = {};
|
|
||||||
|
|
||||||
function setSignals() {
|
|
||||||
if (build.os === "darwin") {
|
|
||||||
ObjectAssign(Signal, MacOSSignal);
|
|
||||||
} else {
|
|
||||||
ObjectAssign(Signal, LinuxSignal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function signal(signo) {
|
function signal(signo) {
|
||||||
if (build.os === "windows") {
|
if (build.os === "windows") {
|
||||||
throw new Error("not implemented!");
|
throw new Error("not implemented!");
|
||||||
|
@ -175,42 +32,6 @@
|
||||||
return new SignalStream(signo);
|
return new SignalStream(signo);
|
||||||
}
|
}
|
||||||
|
|
||||||
const signals = {
|
|
||||||
alarm() {
|
|
||||||
return signal(Signal.SIGALRM);
|
|
||||||
},
|
|
||||||
child() {
|
|
||||||
return signal(Signal.SIGCHLD);
|
|
||||||
},
|
|
||||||
hungup() {
|
|
||||||
return signal(Signal.SIGHUP);
|
|
||||||
},
|
|
||||||
interrupt() {
|
|
||||||
return signal(Signal.SIGINT);
|
|
||||||
},
|
|
||||||
io() {
|
|
||||||
return signal(Signal.SIGIO);
|
|
||||||
},
|
|
||||||
pipe() {
|
|
||||||
return signal(Signal.SIGPIPE);
|
|
||||||
},
|
|
||||||
quit() {
|
|
||||||
return signal(Signal.SIGQUIT);
|
|
||||||
},
|
|
||||||
terminate() {
|
|
||||||
return signal(Signal.SIGTERM);
|
|
||||||
},
|
|
||||||
userDefined1() {
|
|
||||||
return signal(Signal.SIGUSR1);
|
|
||||||
},
|
|
||||||
userDefined2() {
|
|
||||||
return signal(Signal.SIGUSR2);
|
|
||||||
},
|
|
||||||
windowChange() {
|
|
||||||
return signal(Signal.SIGWINCH);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
class SignalStream {
|
class SignalStream {
|
||||||
#disposed = false;
|
#disposed = false;
|
||||||
#pollingPromise = PromiseResolve(false);
|
#pollingPromise = PromiseResolve(false);
|
||||||
|
@ -275,9 +96,6 @@
|
||||||
|
|
||||||
window.__bootstrap.signals = {
|
window.__bootstrap.signals = {
|
||||||
signal,
|
signal,
|
||||||
signals,
|
|
||||||
Signal,
|
|
||||||
SignalStream,
|
SignalStream,
|
||||||
setSignals,
|
|
||||||
};
|
};
|
||||||
})(this);
|
})(this);
|
||||||
|
|
|
@ -106,7 +106,6 @@
|
||||||
|
|
||||||
__bootstrap.denoNsUnstable = {
|
__bootstrap.denoNsUnstable = {
|
||||||
signal: __bootstrap.signals.signal,
|
signal: __bootstrap.signals.signal,
|
||||||
signals: __bootstrap.signals.signals,
|
|
||||||
Signal: __bootstrap.signals.Signal,
|
Signal: __bootstrap.signals.Signal,
|
||||||
SignalStream: __bootstrap.signals.SignalStream,
|
SignalStream: __bootstrap.signals.SignalStream,
|
||||||
emit: __bootstrap.compilerApi.emit,
|
emit: __bootstrap.compilerApi.emit,
|
||||||
|
|
|
@ -37,7 +37,6 @@ delete Object.prototype.__proto__;
|
||||||
const encoding = window.__bootstrap.encoding;
|
const encoding = window.__bootstrap.encoding;
|
||||||
const Console = window.__bootstrap.console.Console;
|
const Console = window.__bootstrap.console.Console;
|
||||||
const worker = window.__bootstrap.worker;
|
const worker = window.__bootstrap.worker;
|
||||||
const signals = window.__bootstrap.signals;
|
|
||||||
const internals = window.__bootstrap.internals;
|
const internals = window.__bootstrap.internals;
|
||||||
const performance = window.__bootstrap.performance;
|
const performance = window.__bootstrap.performance;
|
||||||
const crypto = window.__bootstrap.crypto;
|
const crypto = window.__bootstrap.crypto;
|
||||||
|
@ -609,7 +608,6 @@ delete Object.prototype.__proto__;
|
||||||
// `Deno` with `Deno` namespace from "./deno.ts".
|
// `Deno` with `Deno` namespace from "./deno.ts".
|
||||||
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
|
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
|
||||||
ObjectFreeze(globalThis.Deno.core);
|
ObjectFreeze(globalThis.Deno.core);
|
||||||
signals.setSignals();
|
|
||||||
|
|
||||||
util.log("args", args);
|
util.log("args", args);
|
||||||
}
|
}
|
||||||
|
@ -697,7 +695,6 @@ delete Object.prototype.__proto__;
|
||||||
// existing global `Deno` with `Deno` namespace from "./deno.ts".
|
// existing global `Deno` with `Deno` namespace from "./deno.ts".
|
||||||
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
|
ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs));
|
||||||
ObjectFreeze(globalThis.Deno.core);
|
ObjectFreeze(globalThis.Deno.core);
|
||||||
signals.setSignals();
|
|
||||||
} else {
|
} else {
|
||||||
delete globalThis.Deno;
|
delete globalThis.Deno;
|
||||||
util.assert(globalThis.Deno === undefined);
|
util.assert(globalThis.Deno === undefined);
|
||||||
|
|
|
@ -198,7 +198,7 @@ fn op_run(
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
struct RunStatus {
|
struct ProcessStatus {
|
||||||
got_signal: bool,
|
got_signal: bool,
|
||||||
exit_code: i32,
|
exit_code: i32,
|
||||||
exit_signal: i32,
|
exit_signal: i32,
|
||||||
|
@ -208,7 +208,7 @@ async fn op_run_status(
|
||||||
state: Rc<RefCell<OpState>>,
|
state: Rc<RefCell<OpState>>,
|
||||||
rid: ResourceId,
|
rid: ResourceId,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<RunStatus, AnyError> {
|
) -> Result<ProcessStatus, AnyError> {
|
||||||
let resource = state
|
let resource = state
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.resource_table
|
.resource_table
|
||||||
|
@ -227,7 +227,7 @@ async fn op_run_status(
|
||||||
.expect("Should have either an exit code or a signal.");
|
.expect("Should have either an exit code or a signal.");
|
||||||
let got_signal = signal.is_some();
|
let got_signal = signal.is_some();
|
||||||
|
|
||||||
Ok(RunStatus {
|
Ok(ProcessStatus {
|
||||||
got_signal,
|
got_signal,
|
||||||
exit_code: code.unwrap_or(-1),
|
exit_code: code.unwrap_or(-1),
|
||||||
exit_signal: signal.unwrap_or(-1),
|
exit_signal: signal.unwrap_or(-1),
|
||||||
|
@ -288,13 +288,14 @@ pub fn kill(pid: i32, signal: i32) -> Result<(), AnyError> {
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct KillArgs {
|
struct KillArgs {
|
||||||
pid: i32,
|
pid: i32,
|
||||||
signo: i32,
|
signo: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn op_kill(state: &mut OpState, args: KillArgs, _: ()) -> Result<(), AnyError> {
|
fn op_kill(state: &mut OpState, args: KillArgs, _: ()) -> Result<(), AnyError> {
|
||||||
super::check_unstable(state, "Deno.kill");
|
super::check_unstable(state, "Deno.kill");
|
||||||
state.borrow_mut::<Permissions>().run.check_all()?;
|
state.borrow_mut::<Permissions>().run.check_all()?;
|
||||||
|
|
||||||
kill(args.pid, args.signo)?;
|
let signo = super::signal::signal_str_to_int_unwrap(&args.signo)?;
|
||||||
|
kill(args.pid, signo)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
|
||||||
|
use deno_core::error::type_error;
|
||||||
use deno_core::error::AnyError;
|
use deno_core::error::AnyError;
|
||||||
use deno_core::op_async_unref;
|
use deno_core::op_async_unref;
|
||||||
use deno_core::op_sync;
|
use deno_core::op_sync;
|
||||||
|
@ -53,15 +54,102 @@ impl Resource for SignalStreamResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
fn signal_str_to_int(s: &str) -> Option<libc::c_int> {
|
||||||
|
match s {
|
||||||
|
"SIGHUP" => Some(1),
|
||||||
|
"SIGINT" => Some(2),
|
||||||
|
"SIGQUIT" => Some(3),
|
||||||
|
"SIGILL" => Some(4),
|
||||||
|
"SIGTRAP" => Some(5),
|
||||||
|
"SIGABRT" => Some(6),
|
||||||
|
"SIGBUS" => Some(7),
|
||||||
|
"SIGFPE" => Some(8),
|
||||||
|
"SIGKILL" => Some(9),
|
||||||
|
"SIGUSR1" => Some(10),
|
||||||
|
"SIGSEGV" => Some(11),
|
||||||
|
"SIGUSR2" => Some(12),
|
||||||
|
"SIGPIPE" => Some(13),
|
||||||
|
"SIGALRM" => Some(14),
|
||||||
|
"SIGTERM" => Some(15),
|
||||||
|
"SIGSTKFLT" => Some(16),
|
||||||
|
"SIGCHLD" => Some(17),
|
||||||
|
"SIGCONT" => Some(18),
|
||||||
|
"SIGSTOP" => Some(19),
|
||||||
|
"SIGTSTP" => Some(20),
|
||||||
|
"SIGTTIN" => Some(21),
|
||||||
|
"SIGTTOU" => Some(22),
|
||||||
|
"SIGURG" => Some(23),
|
||||||
|
"SIGXCPU" => Some(24),
|
||||||
|
"SIGXFSZ" => Some(25),
|
||||||
|
"SIGVTALRM" => Some(26),
|
||||||
|
"SIGPROF" => Some(27),
|
||||||
|
"SIGWINCH" => Some(28),
|
||||||
|
"SIGIO" => Some(29),
|
||||||
|
"SIGPWR" => Some(30),
|
||||||
|
"SIGSYS" => Some(31),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fn signal_str_to_int(s: &str) -> Option<libc::c_int> {
|
||||||
|
match s {
|
||||||
|
"SIGHUP" => Some(1),
|
||||||
|
"SIGINT" => Some(2),
|
||||||
|
"SIGQUIT" => Some(3),
|
||||||
|
"SIGILL" => Some(4),
|
||||||
|
"SIGTRAP" => Some(5),
|
||||||
|
"SIGABRT" => Some(6),
|
||||||
|
"SIGEMT" => Some(7),
|
||||||
|
"SIGFPE" => Some(8),
|
||||||
|
"SIGKILL" => Some(9),
|
||||||
|
"SIGBUS" => Some(10),
|
||||||
|
"SIGSEGV" => Some(11),
|
||||||
|
"SIGSYS" => Some(12),
|
||||||
|
"SIGPIPE" => Some(13),
|
||||||
|
"SIGALRM" => Some(14),
|
||||||
|
"SIGTERM" => Some(15),
|
||||||
|
"SIGURG" => Some(16),
|
||||||
|
"SIGSTOP" => Some(17),
|
||||||
|
"SIGTSTP" => Some(18),
|
||||||
|
"SIGCONT" => Some(19),
|
||||||
|
"SIGCHLD" => Some(20),
|
||||||
|
"SIGTTIN" => Some(21),
|
||||||
|
"SIGTTOU" => Some(22),
|
||||||
|
"SIGIO" => Some(23),
|
||||||
|
"SIGXCPU" => Some(24),
|
||||||
|
"SIGXFSZ" => Some(25),
|
||||||
|
"SIGVTALRM" => Some(26),
|
||||||
|
"SIGPROF" => Some(27),
|
||||||
|
"SIGWINCH" => Some(28),
|
||||||
|
"SIGINFO" => Some(29),
|
||||||
|
"SIGUSR1" => Some(30),
|
||||||
|
"SIGUSR2" => Some(31),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
fn signal_str_to_int(s: &str) -> Option<libc::c_int> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn signal_str_to_int_unwrap(s: &str) -> Result<libc::c_int, AnyError> {
|
||||||
|
signal_str_to_int(s)
|
||||||
|
.ok_or_else(|| type_error(format!("Invalid signal : {}", s)))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn op_signal_bind(
|
fn op_signal_bind(
|
||||||
state: &mut OpState,
|
state: &mut OpState,
|
||||||
signo: i32,
|
sig: String,
|
||||||
_: (),
|
_: (),
|
||||||
) -> Result<ResourceId, AnyError> {
|
) -> Result<ResourceId, AnyError> {
|
||||||
super::check_unstable(state, "Deno.signal");
|
super::check_unstable(state, "Deno.signal");
|
||||||
|
let signo = signal_str_to_int_unwrap(&sig)?;
|
||||||
let resource = SignalStreamResource {
|
let resource = SignalStreamResource {
|
||||||
signal: AsyncRefCell::new(signal(SignalKind::from_raw(signo)).expect("")),
|
signal: AsyncRefCell::new(signal(SignalKind::from_raw(signo)).unwrap()),
|
||||||
cancel: Default::default(),
|
cancel: Default::default(),
|
||||||
};
|
};
|
||||||
let rid = state.resource_table.add(resource);
|
let rid = state.resource_table.add(resource);
|
||||||
|
|
|
@ -31,7 +31,7 @@ export async function runWithTestUtil<T>(
|
||||||
}
|
}
|
||||||
const passedTime = performance.now() - start;
|
const passedTime = performance.now() - start;
|
||||||
if (passedTime > 15000) {
|
if (passedTime > 15000) {
|
||||||
proc.kill(2);
|
proc.kill("SIGINT");
|
||||||
await proc.status();
|
await proc.status();
|
||||||
proc.close();
|
proc.close();
|
||||||
throw new Error("Timed out while trying to start wpt test util.");
|
throw new Error("Timed out while trying to start wpt test util.");
|
||||||
|
@ -44,7 +44,7 @@ export async function runWithTestUtil<T>(
|
||||||
return await f();
|
return await f();
|
||||||
} finally {
|
} finally {
|
||||||
if (verbose) console.log("Killing wpt test util.");
|
if (verbose) console.log("Killing wpt test util.");
|
||||||
proc.kill(2);
|
proc.kill("SIGINT");
|
||||||
await proc.status();
|
await proc.status();
|
||||||
proc.close();
|
proc.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue