caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: Catching Break?
@ 1999-01-26  5:17 Frank A. Christoph
  0 siblings, 0 replies; 12+ messages in thread
From: Frank A. Christoph @ 1999-01-26  5:17 UTC (permalink / raw)
  To: Ian T Zimmerman, caml-list

>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?
>
>Ocaml 2.01, Unix (Linux 2.0), libc5, linuxthreads.

Bytecode or native?  For the native compiler, chapter 10.4 of the manual says:

  Signals are detected only when the program performs an allocation
  in the heap.  That is, if a signal is delivered while in a piece of
  code that does not allocate, its handler will not be called until
  the next heap allocation.

--FC




^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Catching Break?
@ 1999-01-26 11:23 Toby Moth
  0 siblings, 0 replies; 12+ messages in thread
From: Toby Moth @ 1999-01-26 11:23 UTC (permalink / raw)
  To: caml-list, itz

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




^ permalink raw reply	[flat|nested] 12+ messages in thread
* Catching Break?
@ 1999-01-25 18:43 Ian T Zimmerman
  1999-01-26  0:24 ` Xavier Leroy
  0 siblings, 1 reply; 12+ messages in thread
From: Ian T Zimmerman @ 1999-01-25 18:43 UTC (permalink / raw)
  To: caml-list


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?

Ocaml 2.01, Unix (Linux 2.0), libc5, linuxthreads.

-- 
Ian T Zimmerman                        <itz@transbay.net>
I came to the conclusion that what was wrong about the guillotine
was that the condemned man had no chance at all, absolutely none.
Albert Camus, _The Outsider_




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~1999-02-10 16:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-26  5:17 Catching Break? Frank A. Christoph
  -- strict thread matches above, loose matches on Subject: below --
1999-01-26 11:23 Toby Moth
1999-01-25 18:43 Ian T Zimmerman
1999-01-26  0:24 ` Xavier Leroy
1999-01-26  6:46   ` Ian T Zimmerman
1999-01-28 11:14     ` Xavier Leroy
1999-01-28 17:33       ` Ian T Zimmerman
1999-02-06  8:24         ` Ian T Zimmerman
1999-02-09  7:02           ` Ian T Zimmerman
1999-02-10 15:48             ` Xavier Leroy
1999-02-05 18:00   ` Ian T Zimmerman
1999-02-08 17:16     ` Xavier Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).