| 1 | (* Dividing by zero stops the program. The program ends with status 2, after the procedures registered |
| 2 | with Rt.atExit, so that what it wrote is out. *) |
| 3 | module StopDivZero; |
| 4 | import Out, Rt; |
| 5 | |
| 6 | |
| 7 | proc bye; |
| 8 | begin |
| 9 | Out.str("bye\n"); |
| 10 | end; |
| 11 | |
| 12 | proc main*; |
| 13 | var a, b: I64; |
| 14 | begin |
| 15 | _ := Rt.atExit(bye); |
| 16 | a := 7; |
| 17 | b := ARGC() - 1; |
| 18 | Out.str("before\n"); |
| 19 | Out.int(a div b); |
| 20 | end; |
| 21 | |
| 22 | end StopDivZero. |