HELP: Determining what signal was received

HELP: Determining what signal was received

Post by Stephen Mathez » Sun, 26 Jun 1994 02:33:58



I am having a problem with signals.  I am writing an application which
needs to catch SIGCLDs.  No problems there, BUT this same program is
also doing a TCP/IP Accept.  If this accept is interrupted by a
SIGCLD, I want it to loop and try again, but if it is interrupted by a
SIGTERM (which another of my processes is sending intentionally) I
want it to stop the accept and return an error.

When the accept is interrupted, it returns errno 4, but there is no
way to determine what signal this was that I can find.

So, is there any way to discover what signal was received.  I am
willing to use regular signals, OR Posix signals.

-Steve

 
 
 

HELP: Determining what signal was received

Post by Casper H.S. D » Mon, 27 Jun 1994 01:32:02



>I am having a problem with signals.  I am writing an application which
>needs to catch SIGCLDs.  No problems there, BUT this same program is
>also doing a TCP/IP Accept.  If this accept is interrupted by a
>SIGCLD, I want it to loop and try again, but if it is interrupted by a
>SIGTERM (which another of my processes is sending intentionally) I
>want it to stop the accept and return an error.
>When the accept is interrupted, it returns errno 4, but there is no
>way to determine what signal this was that I can find.
>So, is there any way to discover what signal was received.  I am
>willing to use regular signals, OR Posix signals.

No, not if you don't install signal handlers that set flags.
E.g.,:

        int termcaught = 0;
        void sigtermhandler(int sig)
        {
            termcaught = 1;
        }

Test this flag after accept returns EINTR and reset it immediately.

An alternative solution is to install two signal handlers with
sigaction().  The first, for SIGCHLD, needs to be installed in
such a way that the system call is restarted.  The second,
for SIGTERM, needs to be installed in such a way that it will
interrupt the system call.  There is no portable solution to
do this.

E.g., in SunOS 4.x you would use the SA_INTERRUPT flag for the
SIGTERM handler and no flag for the SIGCHLD handler.
In SVR4/Solaris 2.x you would use SA_RESTART for SIGCHLD and no
flag for SIGTERM.

Casper

 
 
 

1. Help receiving signal when data is received on socket

Help!!!  I am writing a program that needs to receive a signal when
data arrives on a socket and when the socket is ready to receive
more outgoing data.  I tried the following

  arg = S_INPUT | S_OUTPUT;
  ioctl(plug, I_SETSIG, &arg);
  signal(SIGPOLL, sock_hdlr);

but the signal handler never gets called.

Alan Wenban

2. Signal and directory changes

3. Fatal signal 11 received after receiving/losing IP address with ppp

4. sendmail, DNS & MX records

5. Help....Help...Signal 8 was received

6. disksuite and /dev/md/admin missing problem

7. HELP: RH 6.0 Install: Received Signal 7

8. Log Analyzing

9. Help: GCC 2.7.0 receives a lot of signals 11

10. Help, redhat install exited abnormally, received signal 7

11. Determining IP address of received interface

12. How to determine if I am running libc.so.5

13. How Do I Determine What Shell I am Using?