diff --git a/rubberin b/rubberin index 03e6365..35c7eea 100755 --- a/rubberin +++ b/rubberin @@ -28,6 +28,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +require "English" require "getoptlong" require "rb-inotify" require "pathname" @@ -79,13 +80,13 @@ end def view(infile, mode) case mode when :dvi - exec "xdvi.bin", - "-watchfile", "1", - "-name", "xdvi", infile.with_extname("dvi").to_s + system "xdvi.bin", + "-watchfile", "1", + "-name", "xdvi", infile.with_extname("dvi").to_s when :ps - exec "evince", infile.with_extname("ps").to_s + system "evince", infile.with_extname("ps").to_s when :pdf, :pspdf - exec "evince", infile.with_extname("pdf").to_s + system "evince", infile.with_extname("pdf").to_s end end @@ -168,8 +169,14 @@ compile(infile, mode) puts # Spawn a viewer based on the mode. -viewer_pid = fork -view(infile, mode) if not viewer_pid +pid = $PROCESS_ID +viewer_pid = + fork do + view(infile, mode) + # If xdvi/evince exits, this program should exit too. + puts "#{PROGRAM}: viewer exited, so will I!" + Process.kill("TERM", pid) + end # Handle signals. ["INT", "TERM", "QUIT"].each do |sig| @@ -180,13 +187,6 @@ view(infile, mode) if not viewer_pid end end -# If xdvi/evince exits, this program should exit too. -Signal.trap("CLD") do - puts "#{PROGRAM}: viewer exited, so will I!" - clean(infile) - exit -end - ## Main event loop # Add input file with dependancies to the watch list and start event loop.