… | |
… | |
449 | void |
449 | void |
450 | fork_abort (const char *msg) |
450 | fork_abort (const char *msg) |
451 | { |
451 | { |
452 | if (!fork ()) |
452 | if (!fork ()) |
453 | { |
453 | { |
|
|
454 | fprintf (stderr, "background fork_abort in progress, remove me when debugged.\n");//D |
|
|
455 | |
454 | signal (SIGINT , SIG_IGN); |
456 | signal (SIGINT , SIG_IGN); |
455 | signal (SIGTERM, SIG_IGN); |
457 | signal (SIGTERM, SIG_IGN); |
456 | signal (SIGABRT, SIG_IGN); |
458 | signal (SIGABRT, SIG_IGN); |
|
|
459 | |
|
|
460 | signal (SIGSEGV, SIG_DFL); |
|
|
461 | signal (SIGBUS , SIG_DFL); |
|
|
462 | signal (SIGILL , SIG_DFL); |
|
|
463 | signal (SIGTRAP, SIG_DFL); |
457 | |
464 | |
458 | // try to put corefiles into a subdirectory, if existing, to allow |
465 | // try to put corefiles into a subdirectory, if existing, to allow |
459 | // an administrator to reduce the I/O load. |
466 | // an administrator to reduce the I/O load. |
460 | chdir ("cores"); |
467 | chdir ("cores"); |
461 | |
468 | |
… | |
… | |
469 | |
476 | |
470 | for (int i = 0; i < lim.rlim_cur; ++i) |
477 | for (int i = 0; i < lim.rlim_cur; ++i) |
471 | close (i); |
478 | close (i); |
472 | } |
479 | } |
473 | |
480 | |
|
|
481 | { |
|
|
482 | sigset_t empty; |
|
|
483 | sigemptyset (&empty); |
|
|
484 | sigprocmask (SIG_SETMASK, &empty, 0); |
|
|
485 | } |
|
|
486 | |
|
|
487 | // try to coredump with SIGTRAP |
|
|
488 | kill (getpid (), SIGTRAP); |
474 | abort (); |
489 | abort (); |
475 | } |
490 | } |
476 | |
491 | |
477 | LOG (llevError, "fork abort: %s\n", msg); |
492 | LOG (llevError, "fork abort: %s\n", msg); |
478 | } |
493 | } |