X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=main.c;h=522b2148379cfd14cce8a169fac46775e55feced;hp=f63b9bf49bc35bc26ef2c92cee9e4cce2148a95e;hb=4ec1520c572c4099b478897e4a6ee3a28622ca44;hpb=6f1ac87333108b84a083eedb89ee3eb3d9f4497b diff --git a/main.c b/main.c index f63b9bf..522b214 100644 --- a/main.c +++ b/main.c @@ -314,6 +314,7 @@ int main(int argc, char *argv[]) if (!(strcasecmp(argv[1],"fork"))) { pid_t pid; + FILE *pidfile; /* do daemon fork */ pid = fork(); @@ -344,6 +345,14 @@ int main(int argc, char *argv[]) exit(0); } nooutput = 1; + + /* write pid file */ + pidfile = fopen("/var/run/lcr.pid","w"); + if (pidfile) + { + fprintf(pidfile, "%d\n", getpid()); + fclose(pidfile); + } } else /* if not start */ if (!!strcasecmp(argv[1],"start")) @@ -385,6 +394,21 @@ int main(int argc, char *argv[]) goto free; } +#ifdef WITH_GSM + /* handle gsm */ + if (options.gsm && gsm_init()) + { + fprintf(stderr, "GSM initialization failed.\n"); + goto free; + } +#else + if (options.gsm) + { + fprintf(stderr, "GSM is enabled, but not compiled. Use --with-gsm while configure!\n"); + goto free; + } +#endif + /* read interfaces and open ports */ if (!read_interfaces()) { @@ -410,16 +434,16 @@ int main(int argc, char *argv[]) switch(errno) { case ENOMEM: - fprintf(stderr, "Warning: Not enough memory to lock paging, exitting...\n"); + fprintf(stderr, "Warning: Not enough memory to lock paging.\n"); break; case EPERM: - fprintf(stderr, "Warning: No permission to lock paging, exitting...\n"); + fprintf(stderr, "Warning: No permission to lock paging.\n"); break; case EFAULT: - fprintf(stderr, "Warning: 'Bad address' while locking paging, exitting...\n"); + fprintf(stderr, "Warning: 'Bad address' while locking paging.\n"); break; default: - fprintf(stderr, "Warning: Unknown error %d while locking paging, exitting...\n", errno); + fprintf(stderr, "Warning: Unknown error %d while locking paging.\n", errno); } } @@ -605,6 +629,15 @@ BUDETECT all_idle = 0; BUDETECT +#ifdef WITH_GSM + /* handle gsm */ + if (options.gsm) + while(handle_gsm()) + all_idle = 0; +#endif + +BUDETECT + #if 0 /* check for child to exit (eliminate zombies) */ if (waitpid(-1, NULL, WNOHANG) > 0) @@ -737,6 +770,12 @@ free: if (created_misdn) mISDN_deinitialize(); +#ifdef WITH_GSM + /* free gsm */ + if (options.gsm) + gsm_exit(0); +#endif + /* display memory leak */ #define MEMCHECK(a, b) \ if (b) \