Revision 24764,
797 bytes
checked in by broder, 14 years ago
(diff) |
In discuss:
* Check $PAGER for a pager before falling back on a compiled-in default
("more" by default, but "pager" under our packaging). (Trac: #629)
|
Line | |
---|
1 | /* |
---|
2 | * Pager: Routines to create a pager running out of a particular file |
---|
3 | * descriptor. |
---|
4 | */ |
---|
5 | #ifndef lint |
---|
6 | static char *rcsid_discuss_c = "$Id: pager.c,v 1.4 1999-02-08 14:46:52 danw Exp $"; |
---|
7 | #endif /* lint */ |
---|
8 | |
---|
9 | #include <stdio.h> |
---|
10 | |
---|
11 | int pager_create() |
---|
12 | { |
---|
13 | int filedes[2]; |
---|
14 | int i; |
---|
15 | const char *pager; |
---|
16 | if (!(pager = getenv("PAGER"))) |
---|
17 | pager = PAGER; |
---|
18 | |
---|
19 | if(pipe(filedes) != 0) return(-1); |
---|
20 | |
---|
21 | switch(fork()) { |
---|
22 | case -1: |
---|
23 | return(-1); |
---|
24 | case 0: |
---|
25 | /* |
---|
26 | * Child; dup read half to 0, close all but 0, 1, and 2 |
---|
27 | */ |
---|
28 | (void) dup2(filedes[0], 0); |
---|
29 | for (i=3; i<32; i++) |
---|
30 | (void) close(i); |
---|
31 | (void) execlp("/bin/sh", "/bin/sh", "-c", pager, (char *) NULL); |
---|
32 | exit(1); |
---|
33 | default: |
---|
34 | /* |
---|
35 | * Parent: close "read" side of pipe, return |
---|
36 | * "write" side. |
---|
37 | */ |
---|
38 | (void) close(filedes[0]); |
---|
39 | return(filedes[1]); |
---|
40 | } |
---|
41 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.