kiwanami / emacs-deferred

Simple asynchronous functions for emacs lisp
GNU General Public License v3.0
312 stars 43 forks source link

Detect subprocess termination more robustly #45

Closed liblit closed 7 years ago

liblit commented 7 years ago

Looking at the text of the event string provided to the process sentinel is brittle. We cannot really anticipate the many different values this might have, and therefore cannot anticipate how to respond to all of them. For example, if the subprocess crashes due to a SIGSEGV, then the event text might read segmentation fault (core dumped). The preexisting sentintel code did not check for this specific string, and therefore would never realize that the subprocess had terminated.

The new approach uses Emacs process management functions like (process-live-p ...), (process-status ...), and (process-exit-status ...). These let us determine the process’s current status much more precisely, with more detailed information about how/why it terminated.

liblit commented 7 years ago

Drat, my proposed code uses the string-trim-right function from subr-x, which was not yet available in Emacs 24.3. Should I revise my proposed code so that it still works even under Emacs 24.3?

kiwanami commented 7 years ago

Hi @liblit Thank you for your PR! It's great! I think you have not to revise, because many distributions seem to drop under emacs 24.3. I'd update travis configuration to drop the test for 24.3.

kiwanami commented 7 years ago

Thank you for your updating: version comment and travis config! I merged.

liblit commented 7 years ago

You’re welcome! I am glad to have been able to make a contribution to a project that I find useful.

Would you consider making a new tagged release, perhaps v0.5.1 or v0.6.0? That way I can configure my own package to require a version of your code that includes this fix.

kiwanami commented 7 years ago

Yes, I made a tag as v0.5.1. Would you check it?

liblit commented 7 years ago

Looks great. Thank you!

kiwanami commented 7 years ago

my pleasure.