1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
25 |
|
|
26 |
|
extern int headismine; /* boolean true if header belongs to me */ |
27 |
|
|
28 |
+ |
extern char *progname; /* global program name */ |
29 |
+ |
|
30 |
|
static char *persistfname = NULL; /* persist file name */ |
31 |
|
static int persistfd = -1; /* persist file descriptor */ |
32 |
|
|
97 |
|
|
98 |
|
pfhold() /* holding pattern for idle rendering process */ |
99 |
|
{ |
100 |
< |
char buf[128]; |
100 |
> |
char buf[512]; |
101 |
|
register int n; |
102 |
|
/* close input and output descriptors */ |
103 |
|
close(fileno(stdin)); |
104 |
|
close(fileno(stdout)); |
105 |
|
/* create named pipes for input and output */ |
106 |
< |
if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600) < 0) |
106 |
> |
if (mknod(mktemp(strcpy(inpname,TEMPLATE)), S_IFIFO|0600, 0) < 0) |
107 |
|
goto createrr; |
108 |
< |
if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600) < 0) |
108 |
> |
if (mknod(mktemp(strcpy(outpname,TEMPLATE)), S_IFIFO|0600, 0) < 0) |
109 |
|
goto createrr; |
110 |
< |
sprintf(buf, "%d\n%s\n%s\n", getpid(), inpname, outpname); |
110 |
> |
sprintf(buf, "%s %d\n%s\n%s\n", progname, getpid(), inpname, outpname); |
111 |
|
if (lseek(persistfd, 0L, 0) < 0 || ftruncate(persistfd, 0L) < 0) |
112 |
|
error(SYSTEM, "seek/truncate error on persist file"); |
113 |
|
n = strlen(buf); |
142 |
|
{ |
143 |
|
register char *cp; |
144 |
|
register int nr, n; |
145 |
< |
char buf[4096], *pfin, *pfout; |
145 |
> |
char buf[512], *pfin, *pfout; |
146 |
|
int pid; |
147 |
|
/* load and close persist file */ |
148 |
< |
nr = read(persistfd, buf, sizeof(buf)); |
148 |
> |
nr = read(persistfd, buf, sizeof(buf)-1); |
149 |
|
pfdetach(); |
150 |
|
if (nr < 0) |
151 |
|
error(SYSTEM, "cannot read persist file"); |
152 |
|
buf[nr] = '\0'; |
153 |
< |
if ((cp = index(buf, '\n')) == NULL) |
153 |
> |
if ((cp = index(buf, ' ')) == NULL) |
154 |
|
goto formerr; |
155 |
|
*cp++ = '\0'; |
156 |
< |
if ((pid = atoi(buf)) <= 0) |
156 |
> |
if ((pid = atoi(cp)) <= 0) |
157 |
|
goto formerr; |
156 |
– |
pfin = cp; |
158 |
|
if ((cp = index(cp, '\n')) == NULL) |
159 |
|
goto formerr; |
160 |
+ |
pfin = ++cp; |
161 |
+ |
if ((cp = index(cp, '\n')) == NULL) |
162 |
+ |
goto formerr; |
163 |
|
*cp++ = '\0'; |
164 |
|
pfout = cp; |
165 |
|
if ((cp = index(cp, '\n')) == NULL) |
167 |
|
*cp++ = '\0'; |
168 |
|
if (cp-buf != nr) |
169 |
|
goto formerr; |
170 |
+ |
if (strcmp(buf, progname)) { |
171 |
+ |
sprintf(errmsg, "persist file for %s, not %s", buf, progname); |
172 |
+ |
error(USER, errmsg); |
173 |
+ |
} |
174 |
|
/* wake up rendering process */ |
175 |
|
if (kill(pid, SIGIO) < 0) |
176 |
|
error(SYSTEM, "cannot signal rendering process in io_process"); |