Re: Catching Break?

From: Toby Moth (tm1@cise.npl.co.uk)
Date: Tue Jan 26 1999 - 12:23:51 MET


Date: Tue, 26 Jan 1999 11:23:51 GMT
From: Toby Moth <tm1@cise.npl.co.uk>
Message-Id: <199901261123.LAA07404@squall.cise.npl.co.uk>
To: caml-list@inria.fr, itz@transbay.net
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



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET