Fix infinite loop when exiting viewer
The CLD signal handler cleaned the ini file leading to another CLD signal, which called the handler again etc. Replace this by just killing the main process after the viewer exists in the code for the fork. Also note that we don't know which child process exited in the CLD signal handler. This might be the viewer, but also rubber.
This commit is contained in:
parent
bfdff5745b
commit
c5d363406e
28
rubberin
28
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.
|
||||
|
|
Loading…
Reference in New Issue