[plug] Re: Leon's Sig Code

Michael Hunt michael.j.hunt at usa.net
Fri Mar 2 22:17:01 WST 2001


> > Anyone with a bit more c than me like to put some comments in
> and explain
> > Leons sig line.
>
> 001   #include <signal.h>
> 002   #include <time.h>
> 003   main()
> 004   {
> 005       srandom(time(0));
> 006       for (;;) {
> 007           int pid = random() % 30000;
> 008           if (pid > 1 && pid != getpid())
> 009               kill(pid, random() & 1 ? SIGSTOP : SIGBUS);
> 010           sleep(10);
> 011       }
> 012   }
>
> Line 5, initialise random seed generator based on current time
> Line 6, loop forever
> Line 7, pick a random process ID (0 to 30000)
> Line 8, make sure the process is not current process
> Line 9, kill the process with the reason of "Normal Termination" or "Bus
> Error"
> Line 10, Wait 10 seconds so noone notices it was us.
>
> Leon, been stealing code from M$ again?
>
> David Campbell

Thanks David. Makes a lot more sense when it is formatted nicely. Just
looking at it on one line like that was twisting my brain. I much more used
to the nicetys of python than c




More information about the plug mailing list