1

I have some legacy code on Solaris platform and I would like to port that to Linux, but I am getting some compilation error on Linux. On Solaris, I have the following code snippet:

#include <signal.h>
...
void f() {
    struct sigaction a;
    sigaction(sig,0,&a);
    std::cout << (void *) a.sa_handler
        << ", " << (void *) a.sa_sigaction
        << ", " << a.sa_mask.__sigbits[0]
        << ", " << a.sa_mask.__sigbits[1]
        << ", " << a.sa_mask.__sigbits[2]
        << ", " << a.sa_mask.__sigbits[3]
        << ", " << (void *) a.sa_flags
        << std::endl;
}

When I try to compile on Linux using gcc 4.9.2 (compiles ok on Solaris), I get the following compilation error:

error: struct __sigset_t has no member named __sigbits
     << ", " << a.sa_mask.__sigbits[0]

... and similarly for __sigbits[1], __sigbits[2], __sigbits[3] as well.

Is there any equivalent in Linux?

Dr. Debasish Jana
  • 6,980
  • 4
  • 30
  • 69
  • 2
    What are you trying to do with the `__sigbits` member? Why are you outputting it? The underscore prefix means it's implementation-dependent, as you've found. If *all* you want to do is print it, simply don't bother on Linux. – Roger Lipscombe Apr 11 '17 at 12:27

1 Answers1

1

The POSIX compliant way to do this is to use the sigismember function.

int i;
for (i=0; i<32; i++) {
    printf("signal %d masked: %s\n", i, sigismember(&a.sa_mask, i) ? "yes", "no");
}
dbush
  • 205,898
  • 23
  • 218
  • 273