diff options
author | miwi <miwi@FreeBSD.org> | 2007-02-14 19:00:13 +0800 |
---|---|---|
committer | miwi <miwi@FreeBSD.org> | 2007-02-14 19:00:13 +0800 |
commit | efcd38f265232bc4e4aaca759beead6edca9a340 (patch) | |
tree | 0fd427b3b31ace1ad8375ea782a454968bce7718 /comms/atslog | |
parent | 29c0081608a2f13e6ff8be902367affab27ec2be (diff) | |
download | freebsd-ports-gnome-efcd38f265232bc4e4aaca759beead6edca9a340.tar.gz freebsd-ports-gnome-efcd38f265232bc4e4aaca759beead6edca9a340.tar.zst freebsd-ports-gnome-efcd38f265232bc4e4aaca759beead6edca9a340.zip |
- Fix pidfile check
- Bump PORTREVISION
PR: 109157
Submitted by: Alexander Logvinov <ports@logvinov.com> (maintainer)
Obtained from: developers svn
Diffstat (limited to 'comms/atslog')
-rw-r--r-- | comms/atslog/Makefile | 1 | ||||
-rw-r--r-- | comms/atslog/files/patch-atslogd.c | 109 | ||||
-rw-r--r-- | comms/atslog/files/patch-atslogmaster.in | 54 |
3 files changed, 164 insertions, 0 deletions
diff --git a/comms/atslog/Makefile b/comms/atslog/Makefile index 37e11646a4d3..7341cda0691b 100644 --- a/comms/atslog/Makefile +++ b/comms/atslog/Makefile @@ -7,6 +7,7 @@ PORTNAME= atslog PORTVERSION= 2.1.0 +PORTREVISION= 1 CATEGORIES= comms MASTER_SITES= BERLIOS diff --git a/comms/atslog/files/patch-atslogd.c b/comms/atslog/files/patch-atslogd.c new file mode 100644 index 000000000000..69d22820e2c4 --- /dev/null +++ b/comms/atslog/files/patch-atslogd.c @@ -0,0 +1,109 @@ +--- atslogd/atslogd.c.orig Sun Jan 28 17:52:03 2007 ++++ atslogd/atslogd.c Wed Feb 14 16:22:23 2007 +@@ -143,16 +143,54 @@ + close(hCom); + } + +-static int +-daemonize(void) +-{ +- int rc; +- rc = fork(); +- if (rc == (-1)) +- return (-1); +- if (rc != 0) +- _exit(EX_OK); +- return rc; ++/* taken from the http://www.developerweb.net/forum/archive/index.php/t-3025.html */ ++void daemonize(void) { ++ int fd; ++ switch (fork()) { ++ case 0: ++ break; ++ case -1: ++ // Error ++ fprintf(stderr, "Error demonizing (fork)! %d - %s\n", errno, strerror(errno)); ++ exit(0); ++ break; ++ default: ++ _exit(0); ++ } ++ ++ if (setsid() < 0) { ++ fprintf(stderr, "Error demonizing (setsid)! %d - %s\n", errno, strerror(errno)); ++ exit(0); ++ } ++ switch (fork()) { ++ case 0: ++ break; ++ case -1: ++ // Error ++ fprintf(stderr, "Error demonizing (fork2)! %d - %s\n", errno, strerror(errno)); ++ exit(0); ++ break; ++ default: ++ _exit(0); ++ } ++ /* Are we really need this? */ ++ // chdir("/"); ++ ++ fd = open("/dev/null", O_RDONLY); ++ if (fd != 0) { ++ dup2(fd, 0); ++ close(fd); ++ } ++ fd = open("/dev/null", O_WRONLY); ++ if (fd != 1) { ++ dup2(fd, 1); ++ close(fd); ++ } ++ fd = open("/dev/null", O_WRONLY); ++ if (fd != 2) { ++ dup2(fd, 2); ++ close(fd); ++ } + } + + FILE * +@@ -755,6 +793,9 @@ + argc -= optind; + argv += optind; + ++ if (do_daemonize) ++ daemonize(); ++ + if (logfile) { + errout = fopen(logfile, "at"); + if (errout == NULL) { +@@ -772,28 +813,22 @@ + } + my_syslog("Starting"); + +- if (do_daemonize) +- daemonize(); + + pid = getpid(); +- + if (do_daemonize && pid == (-1)) { + my_syslog("Can't become daemon, exiting"); + my_exit(1); +- } ++ } + pfd = open_pid(); + if (pfd != NULL) { +- (void)fprintf(pfd, "%ld\n", (long)pid); ++ (void)fprintf(pfd, "%d\n", getpid()); + fclose(pfd); + } else { + my_syslog("Can't write to '%s' PID file, exiting", pid_file); + my_exit(1); + } + +- if (do_daemonize) +- pid = daemonize(); +- else +- pid = getpid(); ++ pid = getpid(); + + if (do_daemonize && pid == (-1)) { + my_syslog("Can't become daemon, exiting"); diff --git a/comms/atslog/files/patch-atslogmaster.in b/comms/atslog/files/patch-atslogmaster.in new file mode 100644 index 000000000000..d6b2e228729b --- /dev/null +++ b/comms/atslog/files/patch-atslogmaster.in @@ -0,0 +1,54 @@ +--- include/atslogmaster.in Sun Jan 28 17:52:01 2007 ++++ include/atslogmaster.in Wed Feb 14 16:16:05 2007 +@@ -6,6 +6,7 @@ + NOWDATE=`LANG=en_US;date` + BASENAME=`basename $0` + prefix=@prefix@ ++ATSLOGDpid="" + + # Readin config file + if [ -r @sysconfdir@/atslog.conf ]; then +@@ -26,10 +27,11 @@ + fi + + checkstatus(){ ++ ATSLOGDpid="" + if [ -f $pidfile ] ; then + PID=`cat $pidfile` + if [ "x$PID" != "x" ] && kill -0 $PID 2>/dev/null ; then +- return $PID ++ ATSLOGDpid=$PID + fi + fi + return 0 +@@ -39,10 +41,6 @@ + PATH=$PATH:$bindir:$sharedir + + checkstatus +-ATSLOGDpid=$? +-if [ $ATSLOGDpid -eq 0 ]; then +- ATSLOGDpid="" +-fi + + case "$debug" in + [Yy][Ee][Ss]) +@@ -98,10 +96,6 @@ + echo "$msg8" + fi + checkstatus +- ATSLOGDpid=$? +- if [ $ATSLOGDpid -eq 0 ]; then +- ATSLOGDpid="" +- fi + startloging + if [ $? -eq 0 ] + then +@@ -159,7 +153,7 @@ + fi + sleep 1; + checkstatus +- if [ $? -eq 0 ];then ++ if [ -z ATSLOGDpid ];then + TORETURN=1; # atslogd not started + ERRORMESSAGE=$msg4 + echomess |