|
From: Matthew E. <ma...@gs...> - 2003-07-04 21:40:42
|
I was reviewing the source to corecheck/tests/sigkill.c the other day and
noticed some questionable code, namely:
a) setting errno = 0. errno should never be set by user applications (as
per SUSv3)
b) calling perror() without checking the return code of a library function
first (as per SUSv3)
The following patch addresses these issues and preserves the existing
behaviour of the sigkill.c code.
Comments welcome.
--- corecheck/tests/sigkill.c.orig Fri Jul 4 16:25:28 2003
+++ corecheck/tests/sigkill.c Fri Jul 4 16:41:30 2003
@@ -17,18 +17,19 @@
struct sigaction sa;
int i;
+ int rc;
for (i = 1; i <= 65; i++) {
sa.sa_flags = 0;
sigemptyset( &sa.sa_mask );
sa.sa_handler = abend;
- errno = 0;
fprintf(stderr,"setting signal %d: ", i);
- sigaction (i /*SIGKILL*/, &sa, NULL);
- perror ("");
- errno = 0;
+ rc = sigaction (i /*SIGKILL*/, &sa, NULL);
+ if (rc) perror ("");
+ else fprintf(stderr,"Success\n");
fprintf(stderr,"getting signal %d: ", i);
- sigaction (i /*SIGKILL*/, NULL, &sa);
- perror ("");
+ rc = sigaction (i /*SIGKILL*/, NULL, &sa);
+ if (rc) perror ("");
+ else fprintf(stderr,"Success\n");
fprintf(stderr,"\n");
}
return 0;
--
Matt Emmerton
|