Re: Pentium LIVES

Richard B. Johnson (root@chaos.analogic.com)
Fri, 14 Nov 1997 08:44:33 -0500 (EST)


On Thu, 13 Nov 1997, Hans-Joachim Baader wrote:
> >have a 64-bit random-number generator running on another machine
[SNIPPED]
>
> Where can I get this program? I probably could waste one or more
> machines to run it ;-)
>
Here it is. Note that there is a nonzero possibility of the child
hanging once it destroys its own context. Therefore, you really need
to have another VT up so you can kill the child if necessary. This
allows the program to continue. You could also modify the parent to
kill the child after, say 1 second to stop this problem.

#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include <wait.h>
#include <signal.h>

struct itimerval t={{0x00000000,0x00000000},
{0x00000000,0x0001A000}};

unsigned char c[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc3};

void stopper(int unused)
{
exit(0);
}

void main()
{
int i;
unsigned long *punch0, *punch1;
void(*f)() = (void *) c;
punch0 = (unsigned long *) c;
punch1 = (unsigned long *) &c[4];

for(;;)
{
*punch0 += (unsigned long) rand();
*punch1 += (unsigned long) rand();
switch(fork())
{
case 0:
fprintf(stdout, "Trying %02X %02X %02X %02X %02X %02X %02X %02X %02X\n",
c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], c[8]);
fflush (stdout);
/*
* This stops any "forever" loops that may happen.
*/
(void)signal(SIGALRM, stopper);
(void)setitimer(ITIMER_REAL, &t, &t);

(*f)();
exit(0);
case -1:
fprintf(stderr, "Fork failed\n");
break;
default:
wait(&i);
}
}
}

Cheers,
Dick Johnson

Richard B. Johnson
Project Engineer
Analogic Corporation
Penguin : Linux version 2.1.63 on an i586 machine (66.15 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.