Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem in signal handling? #2869

Closed
vicuna opened this issue Jul 30, 2001 · 2 comments
Closed

problem in signal handling? #2869

vicuna opened this issue Jul 30, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jul 30, 2001

Original bug ID: 458
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Eijiro Sumii
Version: 3.01
OS: Linux 2.2.17 (Debian/potato)
Submission from: 210.238.31.142.tcn-catv.ne.jp (210.238.31.142)

Isn't this a problm of signal handling in ocaml-3.01?

cat caml-signal-test.ml
let signal_handler signal_number =
assert(signal_number = Sys.sigalrm);
exit 0

let _ =
Sys.set_signal Sys.sigalrm (Sys.Signal_handle signal_handler);
ignore (Unix.alarm 1);
Unix.sleep max_int

ocamlc unix.cma caml-signal-test.ml -o caml-signal-test
./caml-signal-test
ocamlopt unix.cmxa caml-signal-test.ml -o caml-signal-test
./caml-signal-test
Fatal error: uncaught exception Assert_failure("caml-signal-test.ml", 37, 72)

The "Changes" file says:

  • Module Sys: signal handling functions are passed the system-independent
    signal number rather than the raw system signal number whenever possible.

Probably the problem above is related to this change?

@vicuna
Copy link
Author

vicuna commented Jul 30, 2001

Comment author: administrator

Signals have two numbers.

@vicuna vicuna closed this as completed Jul 30, 2001
@vicuna
Copy link
Author

vicuna commented Jul 30, 2001

Comment author: administrator

Isn't this a problm of signal handling in ocaml-3.01?

cat caml-signal-test.ml
let signal_handler signal_number =
assert(signal_number = Sys.sigalrm);
exit 0

In general, POSIX standard signals have two numbers: the OS-imposed number
(e.g. 14 for sigalrm under Linux) and the conventional, OS-independent
number found in Sys.sigalrm. So, it's wise not to assume your handler
will be given one of these numbers reliably. Still, if you must:

  • Before 3.01, the handler received the OS-dependent number.
  • In 3.01, the handler receives the conventional number with ocamlc, and
    the OS-dependent number with ocamlopt (the modification wasn't
    reported correctly to the ocamlopt runtime system).
  • In the forthcoming 3.02, the conventional number will be reported for all.

Hope this answers your question.

  • Xavier Leroy

@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant