Browse thread
Re: Catching Break?
- Toby Moth
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Toby Moth <tm1@c...> |
| Subject: | Re: Catching Break? |
Ian T Zimmerman writes: > > Why doesn't this work: > > let main() = > Sys.catch_break true; > try Unix.kill (Unix.getpid()) Sys.sigint > with Sys.Break -> prerr_endline "CAUGHT!"; exit 0 > > let _ = main() > > This program just prints "Fatal error: Uncaught exception Sys.Break" > as if the try block weren't there. Am I overlooking something really > obvious? On the other hand - if one hard-codes in a value for sigint.. let interrupt_handle _ = prerr_endline "Caught C-c"; exit 0;; Sys.set_signal 2 ( Sys.Signal_handle interrupt_handle ); print_string "You have 10 seconds to stop me with C-c"; print_newline (); Unix.sleep 10; print_endline "You failed." then everything works perfectly. I don't understand why there is a discrepancy between the interrupt numbers in sys.ml and those in /usr/include/sys/signal.h ? On the other hand, I know next to nothing about these sorts of things. Toby