summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-10-21 19:52:12 +0000
committerJim Meyering <jim@meyering.net>2001-10-21 19:52:12 +0000
commit48cab72bd10cd430a58abf9a41c9f20eb1ba94e0 (patch)
tree4eed341c37f45aaae7bf499f2e653b685d67707a /src
parente735c8f6e0ab5b42bea1145cc25ddd01dac65813 (diff)
downloadcoreutils-48cab72bd10cd430a58abf9a41c9f20eb1ba94e0.tar.xz
(isaac_seed_machdep): Handle SIGSEGV, too. Ick.
Diffstat (limited to 'src')
-rw-r--r--src/shred.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/shred.c b/src/shred.c
index ddd869fed..e65b1da2f 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -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);
}
}