| 1 |
< |
/* Copyright (c) 1996 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 4 |
> |
static char SCCSid[] = "$SunId$ SGI"; |
| 5 |
|
#endif |
| 6 |
|
|
| 7 |
|
/* |
| 9 |
|
*/ |
| 10 |
|
|
| 11 |
|
#include "standard.h" |
| 12 |
+ |
#include "random.h" |
| 13 |
|
|
| 14 |
|
#ifdef F_SETLKW |
| 15 |
|
#include "paths.h" |
| 171 |
|
char buf[BUFSIZ], *pfin, *pfout, *pferr; |
| 172 |
|
int pid, nfds; |
| 173 |
|
int fdout, fderr = -1; |
| 174 |
+ |
int status = 0; |
| 175 |
|
fd_set readfds, excepfds; |
| 176 |
|
/* load persist file */ |
| 177 |
|
n = 40; |
| 179 |
|
if (!n--) |
| 180 |
|
error(USER, "unattended persist file?"); |
| 181 |
|
pflock(0); |
| 182 |
< |
sleep(15); /* wait until ready */ |
| 182 |
> |
sleep(3+(3*getpid()+random())%13); /* wait until ready */ |
| 183 |
|
pflock(1); |
| 184 |
|
} |
| 185 |
|
if (nr < 0) |
| 270 |
|
close(fderr); |
| 271 |
|
/* close(2); don't close stderr! */ |
| 272 |
|
fderr = -1; |
| 273 |
< |
} else |
| 274 |
< |
do { /* write it all */ |
| 273 |
> |
} else { |
| 274 |
> |
cp[nr] = '\0'; /* deduce status if we can */ |
| 275 |
> |
n = strlen(progname); |
| 276 |
> |
if (!strncmp(cp, progname, n) && |
| 277 |
> |
cp[n++] == ':' && |
| 278 |
> |
cp[n++] == ' ') { |
| 279 |
> |
register struct erract *ep; |
| 280 |
> |
for (ep = erract; ep < erract+NERRS; |
| 281 |
> |
ep++) |
| 282 |
> |
if (ep->pre[0] && |
| 283 |
> |
!strncmp(cp+n, ep->pre, |
| 284 |
> |
strlen(ep->pre))) { |
| 285 |
> |
status = ep->ec; |
| 286 |
> |
break; |
| 287 |
> |
} |
| 288 |
> |
} |
| 289 |
> |
do { /* write message */ |
| 290 |
|
if ((n = write(2, cp, nr)) <= 0) |
| 291 |
|
goto writerr; |
| 292 |
|
cp += n; |
| 293 |
|
} while ((nr -= n) > 0); |
| 294 |
+ |
} |
| 295 |
|
} |
| 296 |
|
/* renderer stdout */ |
| 297 |
|
if (fdout >= 0 && (FD_ISSET(fdout, &readfds) || |
| 311 |
|
} while ((nr -= n) > 0); |
| 312 |
|
} |
| 313 |
|
} |
| 314 |
< |
_exit(0); /* we ought to return renderer error status! */ |
| 314 |
> |
wait(0); /* wait for feeder process */ |
| 315 |
> |
_exit(status); |
| 316 |
|
formerr: |
| 317 |
|
error(USER, "format error in persist file"); |
| 318 |
|
readerr: |