caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrek@autistici.org>
To: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Sys.signal / Sys.set_signal broken in native code?
Date: Sun, 22 Apr 2018 16:33:56 +0300	[thread overview]
Message-ID: <20180422163356.40689256@kiwi.local.tld> (raw)
In-Reply-To: <b0c6739f-35c0-fb19-7d91-473609c786fd@gmail.com>

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

      reply	other threads:[~2018-04-22 13:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-22 13:16 Dmitri Boulytchev
2018-04-22 13:33 ` ygrek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180422163356.40689256@kiwi.local.tld \
    --to=ygrek@autistici.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).