version 1.223, 2015/03/06 09:24:59 |
version 1.224, 2015/03/10 03:02:28 |
|
|
|
|
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/param.h> /* MACHINE */ |
#include <sys/param.h> /* MACHINE */ |
|
#include <sys/wait.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
|
|
|
|
free(defos); |
free(defos); |
|
|
|
/* |
|
* Flush the output and signal end of file. |
|
* If a pager is attached, it allows browsing to the end. |
|
* Otherwise, it does no harm, we are about to exit anyway. |
|
*/ |
|
|
|
fclose(stdout); |
|
|
|
/* |
|
* If we spawned a pager, wait for the user to close it. |
|
* Otherwise, this call fails with no adverse effect. |
|
*/ |
|
|
|
wait(NULL); |
|
|
return((int)rc); |
return((int)rc); |
} |
} |
|
|
Line 951 spawn_pager(void) |
|
Line 967 spawn_pager(void) |
|
progname, strerror(errno)); |
progname, strerror(errno)); |
exit((int)MANDOCLEVEL_SYSERR); |
exit((int)MANDOCLEVEL_SYSERR); |
case 0: |
case 0: |
|
break; |
|
default: |
close(fildes[0]); |
close(fildes[0]); |
if (dup2(fildes[1], STDOUT_FILENO) == -1) { |
if (dup2(fildes[1], STDOUT_FILENO) == -1) { |
fprintf(stderr, "%s: dup output: %s\n", |
fprintf(stderr, "%s: dup output: %s\n", |
progname, strerror(errno)); |
progname, strerror(errno)); |
exit((int)MANDOCLEVEL_SYSERR); |
exit((int)MANDOCLEVEL_SYSERR); |
} |
} |
|
close(fildes[1]); |
return; |
return; |
default: |
|
break; |
|
} |
} |
|
|
/* The original process becomes the pager. */ |
/* The child process becomes the pager. */ |
|
|
close(fildes[1]); |
close(fildes[1]); |
if (dup2(fildes[0], STDIN_FILENO) == -1) { |
if (dup2(fildes[0], STDIN_FILENO) == -1) { |
Line 970 spawn_pager(void) |
|
Line 987 spawn_pager(void) |
|
progname, strerror(errno)); |
progname, strerror(errno)); |
exit((int)MANDOCLEVEL_SYSERR); |
exit((int)MANDOCLEVEL_SYSERR); |
} |
} |
|
close(fildes[0]); |
|
|
pager = getenv("MANPAGER"); |
pager = getenv("MANPAGER"); |
if (pager == NULL || *pager == '\0') |
if (pager == NULL || *pager == '\0') |