From: Florian G. <re...@us...> - 2007-12-09 20:40:39
|
Update of /cvsroot/perfparse/_perfparse/perfparse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7457/perfparse Modified Files: perfparsed.c Log Message: Add error log level and more purging data. Index: perfparsed.c =================================================================== RCS file: /cvsroot/perfparse/_perfparse/perfparse/perfparsed.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** perfparsed.c 28 Sep 2007 21:53:16 -0000 1.7 --- perfparsed.c 9 Dec 2007 20:40:40 -0000 1.8 *************** *** 53,61 **** void daemonize (const char*lock_file) { - int pid; int i; int fd; char str[12]; pid = fork (); if (pid < 0) --- 53,62 ---- void daemonize (const char*lock_file) { int i; int fd; char str[12]; + pid_t pid,sid; + pp_log(__FILE__,__LINE__,LOG_DEBUG,_("daemonize: about to fork\n")); pid = fork (); if (pid < 0) *************** *** 66,84 **** if (pid > 0) { exit (EXIT_SUCCESS); } ! setsid (); ! ! pid = fork (); ! if (pid < 0) ! { ! pp_log(__FILE__,__LINE__,LOG_ERROR, _("daemonize failed (fork problem : errno=%d msg=%s)"),errno,strerror(errno)); exit(EXIT_FAILURE); } - if (pid > 0) - { - exit (EXIT_SUCCESS); - } for (i = getdtablesize (); i >= 0; --i) --- 67,80 ---- if (pid > 0) { + pp_log(__FILE__,__LINE__,LOG_DEBUG,_("daemonize: fork succeeded. Parent process exiting\n")); exit (EXIT_SUCCESS); } ! pp_log(__FILE__,__LINE__,LOG_DEBUG,_("daemonize: fork succeeded. Child process PID: %d\n"),getpid()); ! sid=setsid (); ! if(sid<0) { ! pp_log(__FILE__,__LINE__,LOG_FATAL,_("daemonize: problem creating a new session for daemon process\n")); exit(EXIT_FAILURE); } for (i = getdtablesize (); i >= 0; --i) *************** *** 96,101 **** fd = open (lock_file, O_RDWR | O_CREAT, 0640); ! if (fd < 0) exit (EXIT_FAILURE); if (lockf (fd, F_TLOCK, 0) < 0) { char tmp[20]; --- 92,99 ---- fd = open (lock_file, O_RDWR | O_CREAT, 0640); ! if (fd < 0) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("daemonize: cannot create lockfile %s\n"),lock_file); exit (EXIT_FAILURE); + } if (lockf (fd, F_TLOCK, 0) < 0) { char tmp[20]; *************** *** 115,118 **** --- 113,117 ---- exit (EXIT_SUCCESS); } + snprintf (str, 12, "%ld\n", (long)getpid ()); write (fd, str, strlen (str)); *************** *** 205,212 **** service_log_source = config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG); if(service_log_source[0] && (0 > (open_log_source(service_log_source)))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Could not open log source ('%s') configured in Service_Log"),service_log_source); exit(EXIT_FAILURE); } if((config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT) > 0) && (0 > log_source_new_server(config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT)))) { exit(EXIT_FAILURE); } --- 204,212 ---- service_log_source = config_get_value_as_string(CONFIG_ITEM_ID_SERVICE_LOG); if(service_log_source[0] && (0 > (open_log_source(service_log_source)))) { ! pp_log(__FILE__,__LINE__,LOG_ERROR,_("Could not open log source ('%s') configured in Service_Log"),service_log_source); exit(EXIT_FAILURE); } if((config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT) > 0) && (0 > log_source_new_server(config_get_value_as_integer(CONFIG_ITEM_ID_SERVER_PORT)))) { + pp_log(__FILE__,__LINE__,LOG_ERROR,_("Could not create perfparse server\n")); exit(EXIT_FAILURE); } |