C++ : Interix signals

1.3k Views Asked by At

How to compile/ use signals on the Interix platform? I am unable to get it to compile because Interix appears to be non-POSIX compliant, at least in its implementation of signal.h.

If anyone has found a way to work around this and allow code with signals to compile on Interix, please do let me know how!

Thanks.


Details:

Legacy software in C, C++, and is built on Linux and Interix (for Win XP).

Am getting the following errors during compilation, on Interix only; not on Linux, after adding pthread and signal code. Cannot use pthreads without signals because conflicts with Xmotif (compiles but crashes at run time).

errors due to struct differences:

`struct siginfo' has no member named `si_value'
aggregate `sigval val' has incomplete type and cannot be defined
`struct sigaction' has no member named `sa_sigaction'

errors due to undeclared:

`sigqueue' undeclared
`SA_NODEFER' undeclared
`SA_SIGINFO' undeclared

Other material consulted:

http://www.mail-archive.com/[email protected]/msg10425.html
http://www.gnu.org/software/hello/manual/gnulib/signal_002eh.html
http://en.wikipedia.org/wiki/Interix
http://www.opengroup.org/susv3xbd/signal.h.html

2

There are 2 best solutions below

2
On

According to the POSIX specification, there struct sigaction has no member sa_sigaction, it has sa_handler.

Interix is POSIX compliant in the case, the code you are porting is not.

Note that Linux can be made to work with sa_handler.

You may be able to get it work using the correct #DEFINEs though.

0
On

See the Interix man page and the open group link above.

You can possibly replace the si_sigaction with sa_handler.