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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -