ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/utils.C
(Generate patch)

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.78 by root, Fri May 16 17:09:38 2008 UTC vs.
Revision 1.80 by root, Wed Sep 10 18:18:10 2008 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines