hwhw/kindlepdfviewer — pull request #348 by NiLuJe (2012-10-02 01:43:05+00:00)
Title: Fix input.closeAll & don't leave zombie lipc-wait-event processes

I was looking at kpdf's handling of lipc-wait-event, because I'm doing the same thing with the SS/Fonts hack, and I noticed that it left the process hanging on exit, and left the wrapper script to handle the mess with an ugly killall.

In the course of trying to figure out why that happened, I noticed that input.closeAll/closeInputDevices wasn't ever reaching the block of code handling the termination of the slider watcher fork, because of a simple typo ;).

That still left zombie lipc-wait-event process, though... To fix it, I opted to use a custom popen() implementation (since we have no way of knowing the PID of the process popen creates with the standard API). After a bit of testing, I ended up with this.
It seems to be working properly (the first event *sometimes* doesn't seem to print the 'Going into screensaver' infobox, might be a buffering issue somewhere, but then I'm not sure it worked better before my mess ;p), it doesn't relaunch lipc-wait-event every event, and it properly kills lipc-wait-event on exit. It might need some more massaging to handle every error paths properly, though (might still end up with zombie processes after a crash, for example).