… | |
… | |
33 | #include <signal.h> |
33 | #include <signal.h> |
34 | |
34 | |
35 | #include <global.h> |
35 | #include <global.h> |
36 | #include <material.h> |
36 | #include <material.h> |
37 | |
37 | |
|
|
38 | #include <sys/time.h> |
|
|
39 | #include <sys/resource.h> |
|
|
40 | |
38 | #include <glib.h> |
41 | #include <glib.h> |
39 | |
42 | |
40 | refcnt_base::refcnt_t refcnt_dummy; |
43 | refcnt_base::refcnt_t refcnt_dummy; |
41 | ssize_t slice_alloc; |
44 | ssize_t slice_alloc; |
42 | rand_gen rndm, rmg_rndm; |
45 | rand_gen rndm, rmg_rndm; |
… | |
… | |
447 | fork_abort (const char *msg) |
450 | fork_abort (const char *msg) |
448 | { |
451 | { |
449 | if (!fork ()) |
452 | if (!fork ()) |
450 | { |
453 | { |
451 | signal (SIGABRT, SIG_DFL); |
454 | signal (SIGABRT, SIG_DFL); |
|
|
455 | |
452 | // try to put corefiles into a subdirectory, if existing, to allow |
456 | // try to put corefiles into a subdirectory, if existing, to allow |
453 | // an administrator to reduce the I/O load. |
457 | // an administrator to reduce the I/O load. |
454 | chdir ("cores"); |
458 | chdir ("cores"); |
|
|
459 | |
|
|
460 | // try to detach us from as many external dependencies as possible |
|
|
461 | // as coredumping can take time by closing all fd's. |
|
|
462 | { |
|
|
463 | struct rlimit lim; |
|
|
464 | |
|
|
465 | if (getrlimit (RLIMIT_NOFILE, &lim)) |
|
|
466 | lim.rlim_cur = 1024; |
|
|
467 | |
|
|
468 | for (int i = 0; i < lim.rlim_cur; ++i) |
|
|
469 | close (i); |
|
|
470 | } |
|
|
471 | |
455 | abort (); |
472 | abort (); |
456 | } |
473 | } |
457 | |
474 | |
458 | LOG (llevError, "fork abort: %s\n", msg); |
475 | LOG (llevError, "fork abort: %s\n", msg); |
459 | } |
476 | } |