Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] signals and exceptions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-11-30 (21:21)
From: Andy Chou <acc@C...>
Subject: [Caml-list] signals and exceptions
Can I safely throw an exception inside a signal handler, for the purposes 
of timeout?  For example:

exception Timeout

Sys.set_signal Sys.sigalrm (Sys.Signal_handle (fun _ -> raise Timeout));
       ignore(Unix.alarm 5);
       if Unix.alarm 0 == 0 then
     with Timeout -> printf "TIMEOUT\n");
Sys.set_signal Sys.sigalrm Sys.Signal_ignore;

Will there be an GC problems, etc?  I've noticed that a program that uses
this idiom non-deterministically seg faults.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: