Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000226OCamlOCaml generalpublic2000-11-23 14:132000-11-27 17:11
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
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: drms-3e364ae6.pool.mediaways.net (62.54.74.230)


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.sigint
            (Sys.Signal_handle (fun _ -> prerr_endline"SIGINT"));;
val x : Sys.signal_behavior = Sys.Signal_handle <fun>
# [pressing CTRL-C]
SIGINT
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:
(Signal_default|Signal_ignore)
val h : int -> unit = <fun>
# h 4;;
SIGINT
- : unit = ()

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

In byterun/signals.c, function install_signal_handlers, the record
signal_handlers
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.

Gerd

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000471)
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker