Xref: utzoo comp.unix.internals:2128 comp.unix.wizards:24210 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.unix.internals,comp.unix.wizards Subject: Re: Help with 4.3 mod to kill uninteruptable procs. Message-ID: <16360:Feb2119:57:4591@kramden.acf.nyu.edu> Date: 21 Feb 91 19:57:45 GMT References: <1991Feb19.001941.29928@lynx.CS.ORST.EDU> <4066@stl.stc.co.uk> <10112@dog.ee.lbl.gov> Organization: IR Lines: 36 In article <10112@dog.ee.lbl.gov> torek@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 #include #include #include #include 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 Brought to you by Super Global Mega Corp .com