Re: accept does not return in case a signal arrives

From: Andreas Schwab
Date: Wed Nov 03 2004 - 09:24:39 EST


Gerrit Bruchhäuser <gbruchhaeuser@xxxxxxxxxxxxxxxx> writes:

> Given the following sample:
>
> ,----[ main.cc ]
> | #include <sys/types.h>
> | #include <sys/socket.h>
> | #include <errno.h>
> | #include <string.h>
> | #include <stdio.h>
> | #include <stdlib.h>
> | #include <resolv.h>
> | #include <signal.h>
> |
> | #define CHECK_RET_M(arg, x) \
> | if (-1 == (x) && errno != EINTR) { \
> | printf("System call '%s' failed: %s\n", #arg, strerror(errno)); \
> | exit(1); \
> | }
> |
> | typedef struct sockaddr SA;
> |
> | static void TermHandler(int signu)
> | {
> | // Nothing
> | }
> |
> | int main(int argc, char *argv[])
> | {
> | // Create signal handler 4 SIGTERM
> | signal(SIGTERM, &TermHandler);

Use sigaction.

Andreas.

--
Andreas Schwab, SuSE Labs, schwab@xxxxxxx
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/