| 365 |
|
} |
| 366 |
|
|
| 367 |
|
|
| 368 |
+ |
#ifdef NIX |
| 369 |
+ |
|
| 370 |
+ |
quit(code) |
| 371 |
+ |
int code; |
| 372 |
+ |
{ |
| 373 |
+ |
exit(code); |
| 374 |
+ |
} |
| 375 |
+ |
|
| 376 |
+ |
#else |
| 377 |
+ |
|
| 378 |
+ |
#include <signal.h> |
| 379 |
+ |
|
| 380 |
|
quit(code) /* exit gracefully */ |
| 381 |
|
int code; |
| 382 |
|
{ |
| 383 |
|
int status; |
| 384 |
|
|
| 385 |
< |
if (code == 0) /* reap any children */ |
| 386 |
< |
while (wait(&status) != -1) |
| 387 |
< |
if (code == 0) |
| 388 |
< |
code = status>>8 & 0xff; |
| 385 |
> |
if (code) { /* abnormal exit -- kill children */ |
| 386 |
> |
signal(SIGPIPE, SIG_IGN); |
| 387 |
> |
kill(0, SIGPIPE); |
| 388 |
> |
} |
| 389 |
> |
/* reap any children */ |
| 390 |
> |
while (wait(&status) != -1) |
| 391 |
> |
if (code == 0) |
| 392 |
> |
code = status>>8 & 0xff; |
| 393 |
|
exit(code); |
| 394 |
|
} |
| 395 |
+ |
|
| 396 |
+ |
#endif |