Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000226OCaml~DO NOT USE (was: OCaml general)public2000-11-23 14:132000-11-27 17:11
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000226: Sys.signal returns wrong handler
DescriptionFull_Name: Gerd Stolpmann
Version: 3.00
OS: Linux
Submission from: (

Hello Caml'ers,

I recently found the following incorrect behaviour in O'Caml-3.00.
Sys.signal does not return the previous handler, but the new one:

        Objective Caml version 3.00

# let x = Sys.signal
            (Sys.Signal_handle (fun _ -> prerr_endline"SIGINT"));;
val x : Sys.signal_behavior = Sys.Signal_handle <fun>
# [pressing CTRL-C]
let h = match x with Sys.Signal_handle f -> f;;
Characters 8-45:
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
val h : int -> unit = <fun>
# h 4;;
- : unit = ()

The expected behaviour is that h 4 raises Sys.Break.

In byterun/signals.c, function install_signal_handlers, the record
is modified before the sigaction syscall is performed, and so the lines

  if (oldact == handle_signal) {
    res = alloc_small (1, 0); /* Signal_handle */
    Field(res, 0) = Field(signal_handlers, sig);

will put the closure of the _new_ handler into res. I think the bugfix is
trivial; signal_handlers should be modified after res has been set to the value
of the old handler.


TagsNo tags attached.
Attached Files

- Relationships

-  Notes
administrator (administrator)
2000-11-27 17:11

Fixed on 2000-11-27 by Xavier

- 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