]> diplodocus.org Git - nmh/blob - docs/historical/mh-jun-1982/subs/showfile.c
Create new mh-format function %(ordinal)
[nmh] / docs / historical / mh-jun-1982 / subs / showfile.c
1 #ifdef COMMENT
2 Proprietary Rand Corporation, 1981.
3 Further distribution of this software
4 subject to the terms of the Rand
5 license agreement.
6 #endif
7
8 #include "../mh.h"
9 #include <signal.h>
10 #include <stdio.h>
11
12 showfile(file)
13 char *file;
14 {
15 int pid, wpid, (*intr)(), status;
16 char *vec[4];
17
18 intr = signal(SIGINT, SIG_IGN);
19 m_update();
20 VOID fflush(stdout);
21 if((pid = fork()) == 0) {
22 vec[0] = r1bindex(lproc, '/');
23 vec[1] = file;
24 vec[2] = 0;
25 VOID signal(SIGINT, intr);
26 execv(lproc, vec);
27 fprintf(stderr, "Can't exec ");
28 perror(lproc);
29 goto badleave;
30 } else if(pid == -1) {
31 fprintf(stderr, "No forks!\n");
32 goto badleave;
33 } else
34 while((wpid = wait(&status)) != -1 && wpid != pid) ;
35 VOID signal(SIGINT, intr);
36 if(status & 0377)
37 goto badleave;
38 return(0);
39
40 badleave:
41 VOID fflush(stdout);
42 return(1);
43
44 }
45