ruby - How do I kill a process whose PID is in a PID file? -
i have variable pidfile
, stores pid of process.
how can kill pid in pidfile
programmatically using ruby, assuming know filename, , not actual pid in it.
process.kill(15, file.read('pidfile').to_i)
or even
process.kill 15, file.read('pidfile').to_i
now, like:
system "kill `cat pidfile`" # or `kill \`cat pidfile\``
however, approach has more overhead, vulnerable code injection exploits, less portable, , more of shell script wrapped in ruby opposed actual ruby code.
Comments
Post a Comment