Commit a3da8821 authored by Jeff King's avatar Jeff King Committed by Junio C Hamano

pager: do wait_for_pager on signal death

Since ea27a18c (spawn pager via run_command interface), the
original git process actually does git work, and the pager
is a child process (actually, on Windows it has always been
that way, since Windows lacks fork). After spawning the
pager, we register an atexit() handler that waits for the
pager to finish.

Unfortunately, that handler does not always run. In
particular, if git is killed by a signal, then we exit
immediately. The calling shell then thinks that git is done;
however, the pager is still trying to run and impact the
terminal. The result can be seen by running a long git
process with a pager (e.g., "git log -p") and hitting ^C.
Depending on your config, you should see the shell prompt,
but pressing a key causes the pager to do any terminal
de-initialization sequence.

This patch just intercepts any death-dealing signals and
waits for the pager before dying. Under typical less
configuration, that means hitting ^C will cause git to stop
generating output, but the pager will keep running.
Signed-off-by: default avatarJeff King <>
Signed-off-by: default avatarJunio C Hamano <>
parent 57b235a4
#include "cache.h"
#include "run-command.h"
#include "sigchain.h"
* This is split up from the rest of git so that we can do
......@@ -38,6 +39,13 @@ static void wait_for_pager(void)
static void wait_for_pager_signal(int signo)
void setup_pager(void)
const char *pager = getenv("GIT_PAGER");
......@@ -75,6 +83,7 @@ void setup_pager(void)
/* this makes sure that the parent terminates after the pager */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment