caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Sys.signal / Sys.set_signal broken in native code?
@ 2018-04-22 13:16 Dmitri Boulytchev
  2018-04-22 13:33 ` ygrek
  0 siblings, 1 reply; 2+ messages in thread
From: Dmitri Boulytchev @ 2018-04-22 13:16 UTC (permalink / raw)
  To: caml-list

     Hello,


     Sys.signal / Sys.set_signal doest not work in native code. The 
following code


     let _ =
       Sys.set_signal Sys.sigalrm (Sys.Signal_handle (fun _ -> failwith 
"Timeout..."));
       ignore (Unix.alarm 5);
       while true do () done


     loops forever being compiled with ocamlopt (and raises the expected 
exception with ocamlc). Am I missing something?

     Ubuntu 16.04 64bit, tried with 4.06.0 and 4.06.1


     Best regards,

     Dmitry Boulytchev,

     St Petersburg State University.


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

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

* Re: [Caml-list] Sys.signal / Sys.set_signal broken in native code?
  2018-04-22 13:16 [Caml-list] Sys.signal / Sys.set_signal broken in native code? Dmitri Boulytchev
@ 2018-04-22 13:33 ` ygrek
  0 siblings, 0 replies; 2+ messages in thread
From: ygrek @ 2018-04-22 13:33 UTC (permalink / raw)
  To: caml-list

On Sun, 22 Apr 2018 16:16:59 +0300
Dmitri Boulytchev <dboulytchev@gmail.com> wrote:


>      let _ =
>        Sys.set_signal Sys.sigalrm (Sys.Signal_handle (fun _ -> failwith 
> "Timeout..."));
>        ignore (Unix.alarm 5);
>        while true do () done
> 
> 
>      loops forever being compiled with ocamlopt (and raises the expected 
> exception with ocamlc). Am I missing something?

OCaml runtime turns signals into quasi-asynchronous - they are invoked only at allocation points in native code.
There is no allocation point inside empty loop so there is no chance to call signal handler.
My understanding is that having truly asynchronous signals would be a nightmare wrt runtime state
in signal handler (cf. C signal code restrictions) 

-- 

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

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

end of thread, other threads:[~2018-04-22 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-22 13:16 [Caml-list] Sys.signal / Sys.set_signal broken in native code? Dmitri Boulytchev
2018-04-22 13:33 ` ygrek

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).