]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(isaac_seed_machdep): Handle SIGSEGV, too. Ick.
authorJim Meyering <jim@meyering.net>
Sun, 21 Oct 2001 19:52:12 +0000 (19:52 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 21 Oct 2001 19:52:12 +0000 (19:52 +0000)
src/shred.c

index ddd869fedc0808f6b0872e0e75c9a63beb728112..e65b1da2f5f34be071267b1272efb5ff0c24148f 100644 (file)
@@ -823,16 +823,25 @@ sigill_handler (int signum)
   longjmp (env, 1);  /* Trivial, just return an indication that it happened */
 }
 
+/* FIXME: find a better way.
+   This signal-handling code may well end up being ripped out eventually.
+   An example of how fragile it is, on an i586-sco-sysv5uw7.0.1 system, with
+   gcc-2.95.3pl1, the "rdtsc" instruction causes a segmentation violation.
+   So now, the code catches SIGSEGV.  It'd probably be better to remove all
+   of that mess and find a better source of random data.  Patches welcome.  */
+
 static void
 isaac_seed_machdep (struct isaac_state *s)
 {
-  RETSIGTYPE (*oldhandler) (int);
+  RETSIGTYPE (*old_handler[2]) (int);
 
   /* This is how one does try/except in C */
-  oldhandler = signal (SIGILL, sigill_handler);
+  old_handler[0] = signal (SIGILL, sigill_handler);
+  old_handler[1] = signal (SIGSEGV, sigill_handler);
   if (setjmp (env))  /* ANSI: Must be entire controlling expression */
     {
-      (void) signal (SIGILL, oldhandler);
+      signal (SIGILL, old_handler[0]);
+      signal (SIGSEGV, old_handler[1]);
     }
   else
     {
@@ -860,7 +869,8 @@ isaac_seed_machdep (struct isaac_state *s)
       unsigned long t;
       __asm__ __volatile__ ("rd        %%tick, %0" : "=r" (t));
 # endif
-     (void) signal (SIGILL, oldhandler);
+     signal (SIGILL, old_handler[0]);
+     signal (SIGSEGV, old_handler[1]);
      isaac_seed_data (s, &t, sizeof t);
   }
 }