> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/h/handle_a_signal.md).

# Handle a signal

```ruby
var start = Time.sec

Sig.INT {
    say "Ran for #{Time.sec - start} seconds."
    Sys.exit
}

{ |i|
    say i
    Sys.sleep(0.5)
} * Inf
```

#### Output:

```
1
2
3
4
^CRan for 2 seconds.
```
