diff options
author | Laurent Deniel <laurent.deniel@free.fr> | 2003-05-14 10:31:15 +0000 |
---|---|---|
committer | Laurent Deniel <laurent.deniel@free.fr> | 2003-05-14 10:31:15 +0000 |
commit | ea052d7d2392407bebeb6d078cc598badea339cc (patch) | |
tree | 661d585fb3546bb3a46de43defa69d406867e2bb | |
parent | d791827a65ad8890492d41db0f695341e72282be (diff) |
A correct programming practice is to save errno and restore its value
in all signal handlers that could modify it (i.e. by calling system
calls or worst standard C library functions).
Else the following code for instance is buggy if a signal arises between
the tests:
if (system_call() == -1) {
if (errno == Exxx) {
...
} else {
...
}
}
And MANY (open source or not) programs are broken that way ...
svn path=/trunk/; revision=7664
-rw-r--r-- | tethereal.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tethereal.c b/tethereal.c index 0456a72d8f..f38d02a80f 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1,6 +1,6 @@ /* tethereal.c * - * $Id: tethereal.c,v 1.182 2003/05/04 18:50:51 gerald Exp $ + * $Id: tethereal.c,v 1.183 2003/05/14 10:31:15 deniel Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1432,6 +1432,7 @@ report_counts(void) static void report_counts_siginfo(int signum _U_) { + int sav_errno = errno; /* If we've been told to delay printing, just set a flag asking that we print counts (if we're supposed to), otherwise print the count of packets captured (if we're supposed to). */ @@ -1439,6 +1440,7 @@ report_counts_siginfo(int signum _U_) infoprint = TRUE; else report_counts(); + errno = sav_errno; } #endif /* SIGINFO */ #endif /* HAVE_LIBPCAP */ |