Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000458OCamlOCaml generalpublic2001-07-30 04:352001-07-30 09:26
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
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: 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?

TagsNo tags attached.
Attached Files

- Relationships

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

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

> 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


- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker