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

Strange-ness with SIGINFO and SIGWINCH #30

Closed
erikd opened this issue Dec 19, 2014 · 2 comments
Closed

Strange-ness with SIGINFO and SIGWINCH #30

erikd opened this issue Dec 19, 2014 · 2 comments
Milestone

Comments

@erikd
Copy link
Member

erikd commented Dec 19, 2014

When working on building an x86_64-linux to aarch64-linux cross compiler, I got the error:

libraries/unix/System/Posix/Signals/Exts.hsc:52:1:
    Unacceptable result type in foreign declaration:
      Safe Haskell is on, all FFI imports must be in the IO monad
    When checking declaration:
      foreign import ccall unsafe "static __hsunix_SIGWINCH" sigWINCH :: CInt

which I do not get when building a native compiler. The problems here are as follows:

SIGWINCH not defined

The above foreign import statement is enclosed in an #ifdef like this:

# ifdef SIGWINCH
foreign import ccall unsafe "__hsunix_SIGWINCH"   sigWINCH   :: CInt
# endif

but the SIGWINCH identifier is never defined, because no-one ever added it to the list os signals to look for in configure.ac (the same is true for SIGINFO).

CPP not working correctly during cross-compiling

However, with SIGWINCH undefined, the parser should have dropped that line completely. Since there is no warning on native compiles, this suggests the CPP is not working correctly during cross compiling. Obviously not a problem to be fixed in the unix package, but a contributor to even finding the other problems here.

The #ifdef is not correct.

The current configure script, when it finds a signal SIGXXXX defines CONST_SIGXXXX so the #ifdef should be using that instead of the bare signal name.

Detecting SIGINFO not working correctly.

If I update configure.ac to detect these two signals (on Linux), I get the following in the file include/HsUnixConfig.h:

#define CONST_SIGINFO -1
#define CONST_SIGWINCH 28

The value for SIGWINCH is fine, but the value for SIGINFO is not. It turns out that SIGINFO is a BSD-ism that is not available on Linux. The configure.ac detection code needs to be fixed to leave CONST_SIGINFO undefined on platforms where SIGINFO does not exist.

@erikd
Copy link
Member Author

erikd commented Dec 19, 2014

Furthermore, why is the handling of these two signals so very different from the more commonly used ones in System.Posix.Signals.hs.

I suspect that since these were never used (because of the configure.ac issue) they bit rotted, and should be brought into line with the rest.

@erikd
Copy link
Member Author

erikd commented Dec 19, 2014

A couple of options here:

  • Drop these (ie the file System/Posix/Signals/Exts.hsc) completely. This file was added in 2004 and I can see no evidence of it working correctly after this commit:

    commit 1c4608e
    Author: Simon Marlow marlowsd@gmail.com
    Date: Thu Feb 19 10:05:32 2009 +0000

  • Keep them, but make them work like all the other signals and drop infoEvent and windowChange as they add nothing and have not been available since 2009.

  • Move the definitions of sigINFO and sigWINCH from System/Posix/Signals/Exts.hsc to System/Posix/Signals.hsc and make them work like all the other signals. They aren't POSX, but does that matter? They can be documented as being "non-POSIX" and where they are not available, they will have a value of -1, the same as any other signal that is not available.

I kind of like the last option.

erikd added a commit to erikd/unix that referenced this issue Dec 19, 2014
It seems these two signals have not been working since at least
2009. Detection of these signals seems to have never been added to
the configure.ac script and the code guarded by #ifdef then bit-rotted
(the idiom used to handle these signals seems to have been abandoned
for something simpler/better in 2009). This fix simply handles these
signals the same way the other signals are handled in
System/Posix/Signals.hsc.

Closes: haskell#30
@erikd erikd closed this as completed in 3c4ced4 Dec 19, 2014
@hvr hvr modified the milestone: 2.7.1.0 Dec 19, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants