- print "Terminating lyx instance: " + str(lyx_pid) + "\n"
- intr_system("kill -9 " + str(lyx_pid), True);
- while lyx_exists():
- print "Waiting for lyx to die...\n"
+ print("Forcing quit of lyx instance: " + str(lyx_pid) + "...\n")
+ # \Ax Enter command line is sometimes blocked
+ # \[Escape] works after this
+ sendKeystring("\Ax\[Escape]", lyx_pid)
+ # now we should be outside any dialog
+ # and so the function lyx-quit should work
+ sendKeystring("\Cq", lyx_pid)
+ time.sleep(0.5)
+ if lyx_sleeping():
+ # probably waiting for Save/Discard/Abort, we select 'Discard'
+ sendKeystring("\[Tab]\[Return]", lyx_pid)
+ lcount = 0
+ else:
+ lcount = 1
+ while not lyx_dead():
+ lcount = lcount + 1
+ if lcount > 20:
+ print("LyX still up, killing process and waiting for it to die...\n")
+ intr_system("kill -9 " + str(lyx_pid), True);