Killing the correct process
Maarten Litmaath
maart at cs.vu.nl
Thu Mar 1 14:06:47 AEST 1990
In article <5414 at buengc.BU.EDU>,
bph at buengc.BU.EDU (Blair P. Houghton) writes:
)...
) fp = popen("/bin/ps axl","r");
) while ( fgets(line,sizeof(line),fp) != (char *)NULL )
) if ( uid == parse_for_uid(line) )
) kill( parse_for_pid(line), SIGKILL );
) pclose(fp);
)
)SIG_IGN that!
Between the `ps' and the kill() the user might have created new processes.
Race conditions, babe.
)...
)>I was talking of events with much higher probability.
)
)Wot? You can assign a PID to your own process? I'd like
)to see that...
See above. Talking about assigning your own pid: a friend of mine (Peter
Valkenburg, valke at psy.vu.nl) once wrote a program called `snatch_pid';
you fed it the pid you wanted to grab, then waited an hour or so (ca. 30,000
fork()s on a VAX). The use: if some game initializes its pseudo random
generator with `srand(getpid())'...
) --Blair
) "Blair -v"
"Maarten -SEGV 666 :667 +1 /vmunix"
--
"Belfast: a sentimental journey to the Dark Ages - Crusades & Witchburning
- Europe's Lebanon - Book Now!" | maart at cs.vu.nl, uunet!mcsun!botter!maart
More information about the Comp.unix.questions
mailing list