Help with 4.3 mod to kill uninteruptable procs.
Dan Bernstein
brnstnd at kramden.acf.nyu.edu
Fri Feb 22 06:57:45 AEST 1991
In article <10112 at dog.ee.lbl.gov> torek at elf.ee.lbl.gov (Chris Torek) writes:
> If (A) you have SIGSTOP and (B) signals work correctly,
> the super-user can stop everything, pick out the bad processes, kill
> them, and then resume everything. (This is a bit tricky to get right,
> admittedly.)
What's tricky about it?
#include <sys/time.h>
#include <sys/resource.h>
#include <signal.h>
#include <stdio.h>
#include <errno.h>
extern int errno;
main(argc,argv,envp) /* invoke as, e.g., zonk /bin/csh csh -f; untested */
int argc;
char *argv[];
char *envp[];
{
if (getuid()) { fprintf(stderr,"zonk: fatal: uid not 0\n"); exit(1); }
if (geteuid()) { fprintf(stderr,"zonk: fatal: euid not 0\n"); exit(2); }
if (setpriority(PRIO_PROCESS,0,-20))
fprintf(stderr,"zonk: weird: can't set my priority to -20\n");
if (kill(-1,SIGSTOP) == -1) perror("zonk: warning: first kill failed");
if (kill(-1,SIGSTOP) == -1) perror("zonk: warning: second kill failed");
if (kill(-1,SIGSTOP) == -1) perror("zonk: warning: good-luck kill failed");
for (;;)
{
(void) execve(argv[1],argv + 2,envp);
perror("zonk: critical: exec failed, will try again");
sleep(60);
}
}
---Dan
More information about the Comp.unix.internals
mailing list