Skip to content

Commit

Permalink
Remove example which depends on the removed std/signal (denoland#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k authored Mar 1, 2024
1 parent fb5aef0 commit ab1a59a
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions runtime/tutorials/os_signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,3 @@ Run with:
```shell
deno run signal_listeners.ts
```

## Async iterator example

If you prefer to handle signals using an async iterator, you can use
[`signal()`](https://deno.land/std/signal/mod.ts) API available in `deno_std`:

```ts
/**
* async_iterator_signal.ts
*/
import { signal } from "https://deno.land/std/signal/mod.ts";

const sig = signal("SIGUSR1", "SIGINT");

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

for await (const _ of sig) {
console.log("interrupt or usr1 signal received");
}
```

Run with:

```shell
deno run async_iterator_signal.ts
```

0 comments on commit ab1a59a

Please sign in to comment.