mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
Enforce permissions on kill(), homeDir() and execPath (#2723)
This commit is contained in:
parent
046cccfe17
commit
11c850af42
4 changed files with 24 additions and 3 deletions
|
@ -321,6 +321,22 @@ test(function signalNumbers(): void {
|
|||
|
||||
// Ignore signal tests on windows for now...
|
||||
if (Deno.platform.os !== "win") {
|
||||
test(function killPermissions(): void {
|
||||
let caughtError = false;
|
||||
try {
|
||||
// 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
|
||||
// process - assuming that Deno does not have a special handler set for it
|
||||
// and will just continue even if a signal is erroneously sent.
|
||||
Deno.kill(Deno.pid, Deno.Signal.SIGCONT);
|
||||
} catch (e) {
|
||||
caughtError = true;
|
||||
assertEquals(e.kind, Deno.ErrorKind.PermissionDenied);
|
||||
assertEquals(e.name, "PermissionDenied");
|
||||
}
|
||||
assert(caughtError);
|
||||
});
|
||||
|
||||
testPerm({ run: true }, async function killSuccess(): Promise<void> {
|
||||
const p = run({
|
||||
args: ["python", "-c", "from time import sleep; sleep(10000)"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue