[Haskell-cafe] gracefully invoking `less` using System.Process (and ignoring ctrl-c)
guillaumh at gmail.com
Fri Dec 12 17:19:31 UTC 2014
I'm looking at a bug that we should fix for the 2.10 release of darcs.
I'd like to make the invocation of the pager (most of the time `less`)
as identical to git as possible.
Currently darcs has a workaround for the "resource vanished (broken
pipe)" problem (that happens when you leave `less` before all of the
text has been read by it). The workaround involves creating a
temporary file and then passing it to less . This works but it's
slow (for big inputs) and ugly IMO.
I have a fix proposal  that is made of two changes:
* use System.Process.createProcess (just to update the code), and
* in the "ortryrunning" function (that chains attempts at calling
various pagers until one works), ignoring IOError's of the kind
ResourceVanished (otherwise we would invoke every pager in the chain
if we quit them before they read all their input)
The problem is that pressing CTRL-C in `less` now kills everything (darcs+less).
Is there a way to fix this?
Note that the darcs executable runs inside of the function
withSignalHandled , which defines its behaviour with respect to
More information about the Haskell-Cafe