English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners