I need to run a subprocess, execute some code, and then kill the started process; I don't need the output of this subprocess. I tried something like this:
def start
@@rtorrentIO ||= IO.popen("rtorrent")
sleep 0.5
end
def stop
Process.kill(9, @@rtorrentIO.pid) if defined? @@rtorrentIO
@@rtorrentIO = nil
end
start
sleep 0.5
#some code there
stop
but the terminal doesn't react to any actions that I did (even Ctrl+C escape). What am I doing wrong?
UPDATE:
I was a little mistake in the initial conditions. In fact terminal react for all my actions but I don't see any symbols that I write before command executes. In the picture below I consistently execute the following commands: mangaParser.rb; whoami; ps;
And that was I get to output:

However, if i try to break runned command with Ctrl+C escape, it was failure (e.g. I can't break the following sequence of command without other terminal: mangaParser.rb; ping google.com;)
@@torrentIO.pidbefore doingProcess.kill?