Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000458OCaml~DO NOT USE (was: OCaml general)public2001-07-30 04:352001-07-30 09:26
Assigned To 
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000458: problem in signal handling?
DescriptionFull_Name: Eijiro Sumii
Version: 3.01
OS: Linux 2.2.17 (Debian/potato)
Submission from: (

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

> cat
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 -o caml-signal-test
> ./caml-signal-test
> ocamlopt unix.cmxa -o caml-signal-test
> ./caml-signal-test
Fatal error: uncaught exception Assert_failure("", 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?

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
administrator (administrator)
2001-07-30 09:26

Signals have two numbers.
administrator (administrator)
2001-07-30 12:00

> Isn't this a problm of signal handling in ocaml-3.01?
> > cat
> 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

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker