Repository : http://git.fedorahosted.org/git/?p=conga-luci-1stgen.git
On branch : RHEL5-active
commit 165345341ea3d9a9f81ffed664f86880122734d9 Author: Jan Pokorný jpokorny@redhat.com Date: Wed Aug 15 16:54:50 2012 +0200
ricci: daemon_init: further unify with rgmanager's one
Signed-off-by: Jan Pokorný jpokorny@redhat.com
ricci/common/daemon_init.c | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ricci/common/daemon_init.c b/ricci/common/daemon_init.c index 5737249..c3295c7 100644 --- a/ricci/common/daemon_init.c +++ b/ricci/common/daemon_init.c @@ -1,5 +1,5 @@ /* - Copyright Red Hat, Inc. 2002-2008 + Copyright Red Hat, Inc. 2002-2012 Copyright Mission Critical Linux, 2000
This program is free software; you can redistribute it and/or modify it @@ -20,8 +20,6 @@ /** @file * daemon_init function, does sanity checks and calls daemon(). * - * $Id: daemon_init.c,v 1.1.2.2 2008/05/12 15:13:32 rmccabe Exp $ - * * Author: Jeff Moyer moyer@mclinux.com */ /* @@ -74,7 +72,6 @@ check_pid_valid(pid_t pid, char *prog)
snprintf(dirpath, sizeof (dirpath), "/proc/%d", pid); if ((dir = opendir(dirpath)) == NULL) { - closedir(dir); return 0; /* Pid has gone away. */ } closedir(dir); @@ -150,8 +147,11 @@ check_process_running(char *prog, pid_t * pid) if (fp == NULL) { /* error */ return 0; } - fscanf(fp, "%d\n", &oldpid); + ret = fscanf(fp, "%d\n", &oldpid); fclose(fp); + if ((ret == EOF) || (ret != 1)) + return 0; + if (check_pid_valid(oldpid, cmd)) { *pid = oldpid; return 1; @@ -228,8 +228,14 @@ daemon_init(char *prog) exit(1); }
- daemon(0, 0); + if (daemon(0, 0)) { + fprintf(stderr, "daemon_init: Unable to daemonize.\n"); + exit(1); + }
update_pidfile(prog); - nice(-1); + if (nice(-1) < 0) + fprintf(stderr, "daemon_init: Unable to renice.\n"); + + //mlockall(MCL_CURRENT | MCL_FUTURE); }
conga-luci-1stgen-commits@lists.fedorahosted.org