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

Signalhandling not detailed enough: sigaction(2) not mentioned anywhere #6018

Closed
vicuna opened this issue May 22, 2013 · 2 comments
Closed

Comments

@vicuna
Copy link

vicuna commented May 22, 2013

Original bug ID: 6018
Reporter: oliver
Status: closed (set by @xavierleroy on 2015-12-11T18:19:35Z)
Resolution: not a bug
Priority: normal
Severity: minor
Category: documentation

Bug description

The reliable Unix signals need the function sigaction(2) to install the signal-related action.
sigaction(2) is one of the signal functions, accompanied by sigprocmask(2), sigsuspend(2), sigpending(2).

In the doc for the Unix-module, there is only mentioned, that signal numbers must be taken from Sys-module, and that signal handlers also will be set via Sys-module.

When reading the description in Sys-module it is also not mentioned that sigaction(2) is used.

So, when looking only at the docs for Sys- and Unix-module, it is not clear if signal(2) or sigaction(2) is used to establish the signal handler.

Someone coming from the C-world will miss sigaction(2) at least to be mentioned. That it is used as "hidden magic" under the hood of Sys-module is not enough, IMHO.
sigpending(2) and the other signal-functions are also available in Unix-module.

So it would be more consequently (from the Unix-systems view) to also make sigaction(2) available in Unix-module.

To have all signal-installation handling in Sys-module also makes sense somehow (regarding platform-independence), but then it should be mentioned that sigaction(2) is used in case of Unix-systems via the Sys-module. (This is not so consequently regarding platform-seperation, because Unix-stuff should belong to Unix-module).

The state of the docs and implementation looks like a compromise between platform-independence in usage of the modules vs. platform-seperation.
Put signal-installation into Sys independent of platform makes sense; seperate Unixoid systemhandler-installation intto Unix-module also makes sense.
So, the way it is done at the moment, is ok from a certain point of view.

But in in both cases, the documentation need to mention sigaction(2) somehow, somewhere; otherwise switching from C to OCaml can be confusing at this point.

Something like:
"OCaml is weird, it has sigprocmask(2) and sigpending(2) and so on, but does
not provide sigaction(2). Can this be seen as a reliable language?
Is there some hidden sigaction(2) magic? If so, it might be seen as
reliable, but weird."

@vicuna
Copy link
Author

vicuna commented Jun 10, 2013

Comment author: @xavierleroy

This looks like a fine hair being split.

All POSIX-compliant systems define signal() [from the C standard library] on top of sigaction() [from POSIX].

Likewise, OCaml defines Sys.signal in terms of sigaction() on POSIX hosts and of signal() on other hosts. We're not stupid.

@vicuna
Copy link
Author

vicuna commented Jun 10, 2013

Comment author: oliver

I did not said, you are stupid.
Contrary... I think the OCaml core developers are very intelligent and did good work.

But the problem between signal() and sigaction()/sigprocmask()/...
is mentioned in W.R. Stevens' "Advanced Programming in the Unix Environment", a fundamental book on unix programming, as you surely know.

So, who read that book and did programming in C, then switch to OCaml, will miss sigaction()-call.

This is especially, because the other calls, like sigprocmask() are not also
hidden by OCaml abstractions.
So on the one hand sigaction() is abstracted away, on the other hand, the other functions are available.

And regarding the Stevens' book (which I think even today is some kind of reference), this IMHO does not look like "a fine hair being split".

It would be just some sentences in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant