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

Sys.signal returns wrong handler #2619

Closed
vicuna opened this issue Nov 23, 2000 · 1 comment
Closed

Sys.signal returns wrong handler #2619

vicuna opened this issue Nov 23, 2000 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 23, 2000

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

Bug description

Full_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

[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 =

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

@vicuna
Copy link
Author

vicuna commented Nov 27, 2000

Comment author: administrator

Fixed on 2000-11-27 by Xavier

@vicuna vicuna closed this as completed Nov 27, 2000
@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