X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=pager.c;h=86facec7b417b26a7dbd9b3c1338149fcecd5588;hb=c89e32414516e906520e9bdd809560971eb52ef5;hp=f19ddbc87df04f117cd5e39189c8322fd5f29d68;hpb=ff6e93fe605b748055267fd325c760d0f32dcf92;p=git.git diff --git a/pager.c b/pager.c index f19ddbc87..86facec7b 100644 --- a/pager.c +++ b/pager.c @@ -1,5 +1,6 @@ #include "cache.h" #include "run-command.h" +#include "sigchain.h" /* * This is split up from the rest of git so that we can do @@ -8,7 +9,7 @@ static int spawned_pager; -#ifndef __MINGW32__ +#ifndef WIN32 static void pager_preexec(void) { /* @@ -20,8 +21,6 @@ static void pager_preexec(void) FD_ZERO(&in); FD_SET(0, &in); select(1, &in, NULL, &in, NULL); - - setenv("LESS", "FRSX", 0); } #endif @@ -38,6 +37,13 @@ static void wait_for_pager(void) finish_command(&pager_process); } +static void wait_for_pager_signal(int signo) +{ + wait_for_pager(); + sigchain_pop(signo); + raise(signo); +} + void setup_pager(void) { const char *pager = getenv("GIT_PAGER"); @@ -62,7 +68,11 @@ void setup_pager(void) pager_argv[2] = pager; pager_process.argv = pager_argv; pager_process.in = -1; -#ifndef __MINGW32__ + if (!getenv("LESS")) { + static const char *env[] = { "LESS=FRSX", NULL }; + pager_process.env = env; + } +#ifndef WIN32 pager_process.preexec_cb = pager_preexec; #endif if (start_command(&pager_process)) @@ -75,6 +85,7 @@ void setup_pager(void) close(pager_process.in); /* this makes sure that the parent terminates after the pager */ + sigchain_push_common(wait_for_pager_signal); atexit(wait_for_pager); }