| 1 | (* Rt.exitStatus is 0 in main and the status exit was given in the |
| 2 | procedures atExit registered, also when a check or stop ends the |
| 3 | program. *) |
| 4 | module ExitStatus; |
| 5 | import Out, Rt; |
| 6 | |
| 7 | proc report; |
| 8 | begin |
| 9 | Out.str("ending with "); Out.int(Rt.exitStatus()); Out.str("\n"); |
| 10 | end; |
| 11 | |
| 12 | proc main*: INT; |
| 13 | begin |
| 14 | _ := Rt.atExit(report); |
| 15 | Out.int(Rt.exitStatus()); Out.str(" in main\n"); |
| 16 | Rt.exit(7); |
| 17 | return 0; |
| 18 | end; |
| 19 | |
| 20 | end ExitStatus. |