// Allow process to lock 500M of available memory
rlim.rlim_max = 500*1024*1024;
rlim.rlim_cur = rlim.rlim_max;
if(setrlimit(RLIMIT_MEMLOCK, &rlim))
perror("Unable to enable memory locking");
#if COREDUMP
rlim.rlim_max = 1024*1024*1024;
rlim.rlim_cur = rlim.rlim_max;
if(setrlimit(RLIMIT_CORE, &rlim))
perror("Unable to enable core dump");
printf("Set to core dump\n");
#endif
// Relinqish root ownership
if(geteuid() == 0){
realTime = 1;
seteuid(getuid());
setegid(getgid());
}
// Lock in all of the pages of this application
if(mlockall(MCL_CURRENT | MCL_FUTURE) < 0)
fprintf(stderr, "Warning: unable to lock in memory pages\n");
// Make sure master thread ignores termination signals sent to the other threads
// Also ignore file size signal, the write function will return an error instead.
sigemptyset(&sigm);
sigaddset(&sigm, SIGUSR1);
sigaddset(&sigm, SIGXFSZ);
sigaddset(&sigm, SIGPIPE);
sigprocmask(SIG_BLOCK, &sigm, 0);
// Setup signals for program crash
signalSet(SIGSEGV, sigCrash);
signalSet(SIGHUP, sigCrash);
signalSet(SIGILL, sigCrash);
signalSet(SIGABRT, sigCrash);
signalSet(SIGFPE, sigCrash);
signalSet(SIGBUS, sigCrash);
openlog("tmsServer", LOG_CONS, LOG_DAEMON);
for(a = 1; a < argc; a++){
if(argv[a][0] == '-'){
switch(argv[a][1]){