1 /*- 2 * Copyright (c) 1990 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)instr.c 5.3 (Berkeley) 04/26/93"; 10 #endif /* not lint */ 11 12 #include <sys/types.h> 13 #include <sys/wait.h> 14 #include <sys/errno.h> 15 #include <sys/stat.h> 16 17 #include <curses.h> 18 #include <stdio.h> 19 #include <stdlib.h> 20 #include <string.h> 21 #include <unistd.h> 22 23 #include "deck.h" 24 #include "cribbage.h" 25 #include "pathnames.h" 26 27 void 28 instructions() 29 { 30 extern int errno; 31 struct stat sb; 32 union wait pstat; 33 pid_t pid; 34 char *pager, *path; 35 36 if (stat(_PATH_INSTR, &sb)) { 37 (void)fprintf(stderr, "cribbage: %s: %s.\n", _PATH_INSTR, 38 strerror(errno)); 39 exit(1); 40 } 41 switch (pid = vfork()) { 42 case -1: 43 (void)fprintf(stderr, "cribbage: %s.\n", strerror(errno)); 44 exit(1); 45 case 0: 46 if (!(path = getenv("PAGER"))) 47 path = _PATH_MORE; 48 if (pager = rindex(path, '/')) 49 ++pager; 50 pager = path; 51 execlp(path, pager, _PATH_INSTR, (char *)NULL); 52 (void)fprintf(stderr, "cribbage: %s.\n", strerror(errno)); 53 _exit(1); 54 default: 55 do { 56 pid = waitpid(pid, (int *)&pstat, 0); 57 } while (pid == -1 && errno == EINTR); 58 if (pid == -1 || pstat.w_status) 59 exit(1); 60 } 61 } 62