From: "Suraj N. Kurapati" Date: 2006-09-27T03:05:23+09:00 Subject: Re: Kill process by his name -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Eero Saynatkari wrote: > David Corticchiato wrote: >> is it possible to kill a process by his name without using directly a >> program of the OS used ? I mean without using system(...) or `...`. > > No. That is not generally supported even on POSIX systems > (hence the killall command). You can parse the process list, > grab the PID and issue a kill on it. Here is an example. Suppose you wanted to kill all existing processes of the current program: pidList = `ps -C #{File.basename $0} -o pid`.split.map! {|s| s.to_i} pidList.shift # discard header pidList.reject! {|pid| pid == $$} pidList.each do |pid| Process.kill :SIGTERM, pid end -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) iD8DBQFFGWv0mV9O7RYnKMcRAgTbAKCkt5t3NO5U/9lzWmGGZdaWUKjVZwCgs6vm jMtlv5H1cVSxowRoGJITXA4= =/TEd -----END PGP SIGNATURE-----