sigaction.sa_handler and Solaris Sparcworks 4.X C++?

sigaction.sa_handler and Solaris Sparcworks 4.X C++?

Post by Buc Roger » Thu, 26 Oct 1995 04:00:00



I'm having trouble getting the Sparcworks 4.X compiler to compile
POSIX.1 signal handling code (an example is at the end of this message).

It appears that the sys/signal.h declaration for the sigaction struct
is in error, in that sigaction.sa_handler is declared as a void(*)()
rather than a void(*)(int).

As I understand it, this declaration works fine under "ANSI" or "standard"
C, but under C++ a () argument declaration is the SAME as (void), unlike
"ANSI" or "standard" C.

For now, I've "casted-away" this problem, but would like to have a cleaner
solution. Note that gcc and other compilers on other platforms do not
exhibit
this symptom.

**example.c:
#include <signal.h>

void signal_handler(int)
{

Quote:}

void funct()
{
  struct sigaction        action;

  action.sa_handler = signal_handler; /*ERROR: cannot assign void(*)(int)
to void(*)()*/

  action.sa_handler = SIG_IGN; /*ERROR: cannot assign void(*)(int) to
void(*)()*/

Quote:}

- - - -
**sys/signal.h:
struct sigaction {
        int sa_flags;
        union {
                void (*_handler)();
        }       _funcptr;
Quote:};

#define sa_handler      _funcptr._handler
- - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Open Port Technology

 
 
 

sigaction.sa_handler and Solaris Sparcworks 4.X C++?

Post by Buc Roger » Fri, 27 Oct 1995 04:00:00


I got an answer from Sun admitting a C++ incompatibility in
signal.h:
- - - -
From /usr/include/sys/signal.h (On Solaris 2.5 - not yet released):

Both are incorrect :-(

/*
 * The signal handler routine can have either one or three arguments.
 * Existing C code has used either form so not specifing the arguments
 * neatly finesses the problem.  C++ doesn't accept this.  To C++
 * "(*sa_handler)()" indicates a routine with no arguments (ANSI C would
 * specify this as "(*sa_handler)(void)").  One or the other form must be
 * used for C++ and the only logical choice is "(*sa_handler)(int)" to
allow
 * the SIG_* defines to work.  "(*sa_sigaction)(int, siginfo_t *, void *)"
 * can be used for the three argument form.
 */

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

URL: http://www.mcs.com/~buc/home.html URL:
ftp://ftp.mcs.com/mcsnet.users/buc/

 
 
 

sigaction.sa_handler and Solaris Sparcworks 4.X C++?

Post by Casper H.S. Dik - Network Security Engine » Sat, 28 Oct 1995 04:00:00



>I'm having trouble getting the Sparcworks 4.X compiler to compile
>POSIX.1 signal handling code (an example is at the end of this message).
>It appears that the sys/signal.h declaration for the sigaction struct
>is in error, in that sigaction.sa_handler is declared as a void(*)()
>rather than a void(*)(int).

That's a bug in Sun's include files;

change it to read:

#ifdef  __cplusplus
                void (*_handler)(int);
#else
                void (*_handler)();
#endif

instead of just:

                void (*_handler)();

(Though the __cplusplus branch should really also be used for ANSI C)

Casper
--
Expressed in this posting are my opinions.  They are in no way related
to opinions held by my employer, Sun Microsystems.

 
 
 

1. sigaction.sa_handler = SIG_IGN (SunOS 5.4, g++ 2.7.2) give ANSI C++ warning

Hi,

I get the following warning:

process.cc:192: warning: ANSI C++ prohibits conversion from `(int)' to `(...)'

Here is the relevant part of my source:

  {
    struct sigaction act;

    act.sa_handler = SIG_IGN;
    act.sa_flags   = 0;

    sigemptyset(&act.sa_mask);

    if (sigaction(SIGTTOU, &act, NULL) != 0) PANIC;
    if (sigaction(SIGTTIN, &act, NULL) != 0) PANIC;
    if (sigaction(SIGTSTP, &act, NULL) != 0) PANIC;
  }

The line tha gives the warning is the "act.sa_handler = SIG_IGN" line. I don't
know why I'm getting this warning. The books I have say this is okay (Rago:
UNIX SysV Net. Prog.), the man page says this is okay as well. The sa_handler
field can be either:

a void (*handler)() or SIG_IGN or SIG_DFL

What gives? I'm using  SunOS 5.4 and g++ 2.7.2.

I'd appreciate being CC'ed as well. TIA.

Dave.
--
i'm on a huge wispy rhino fart

2. Toshiba and XF 4.0.2

3. Integrating SparcWorks C++ and Apex C++

4. Telnet

5. gethostname() with Solaris Sparcworks 4.X C++?

6. TCP/IP D.E. Comer Volume III

7. Wanted to buy: Solaris 8 admin training guide (Sun SA-238 or SA-288)

8. 430LX Chipset problems?

9. use of sigaction() in C++

10. Wish to buy Sun Sparcworks/Workshop for C++

11. Using gdb 4.16 with SparcWorks C++ 4.1?

12. Where can I find SparcWorks C++ compiler 4.2?

13. where can I find: SPARCWorks Compiler C/C++ 4.2 for x86