From ce36dd0994ffa833ff0ce18e57a8776ff1103d8d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 20 Oct 2003 21:53:46 +0000 Subject: commit release 0.3 git-svn-id: file:///home/lennart/svn/public/libdaemon/trunk@41 153bfa13-eec0-0310-be40-b0cb6a0e1b4b --- Makefile.am | 5 ++++- bootstrap.sh | 4 +--- configure.ac | 10 +++++++--- doc/Makefile.am | 3 ++- doc/README.html.in | 21 +++++++++++---------- doc/style.css | 19 +++++++++++++++++++ examples/testd.c | 7 +++++++ src/Makefile.am | 1 + src/dpid.c | 31 +++++++++++++++++++++++++++++++ src/dpid.h | 14 ++++++++++++++ 10 files changed, 97 insertions(+), 18 deletions(-) diff --git a/Makefile.am b/Makefile.am index 63b1d96..05b43a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,4 +35,7 @@ homepage: cp $$HOME/homepage/lennart/projects/libdaemon/README.html $$HOME/homepage/lennart/projects/libdaemon/index.html cp -av doc/reference/ $$HOME/homepage/lennart/projects/libdaemon/ -.PHONY: homepage +distcleancheck: + @: + +.PHONY: homepage distcleancheck diff --git a/bootstrap.sh b/bootstrap.sh index 203f27b..a520e21 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -24,8 +24,6 @@ if [ "x$1" = "xam" ] ; then else set -ex - #make maintainer-clean || true - rm -rf autom4te.cache rm -f config.cache @@ -35,6 +33,6 @@ else automake -a -c autoconf -Wall - ./configure "$@" + ./configure --sysconfdir=/etc "$@" fi diff --git a/configure.ac b/configure.ac index 884d8d0..7deb5d8 100644 --- a/configure.ac +++ b/configure.ac @@ -20,23 +20,27 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. AC_PREREQ(2.57) -AC_INIT([libdaemon], [0.3], [mzqnrzba@itaparica.org]) +AC_INIT([libdaemon], [0.3], [mzqnrzba (at) 0pointer (dot) de]) AC_CONFIG_SRCDIR([src/dfork.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign -Wall]) -AM_MAINTAINER_MODE # Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_LIBTOOL +AC_SUBST(PACKAGE_URL, [http://0pointer.de/lennart/projects/libdaemon/]) + # If using GCC specifiy some additional parameters if test "x$GCC" = "xyes" ; then CFLAGS="$CFLAGS -pipe -Wall" fi -# Checks for libraries. +if type -p stow > /dev/null && test -d /usr/local/stow ; then + AC_MSG_NOTICE([*** Found /usr/local/stow: installing to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***]) + AC_PREFIX_DEFAULT([/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}]) +fi # Checks for header files. AC_HEADER_STDC diff --git a/doc/Makefile.am b/doc/Makefile.am index c9f5c50..fe60314 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -17,8 +17,9 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. noinst_DATA = README.html README reference +EXTRA_DIST = $(noinst_DATA) style.css README.html.in reference + MAINTAINERCLEANFILES = README README.html -EXTRA_DIST = style.css README README.html README.html.in reference CLEANFILES = if USE_DOXYGEN diff --git a/doc/README.html.in b/doc/README.html.in index 0ca5307..1d5ee03 100644 --- a/doc/README.html.in +++ b/doc/README.html.in @@ -42,14 +42,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

News

-
Thu July 10 2003:
-

Version 0.3 released; changes include: documentation update, build fixes, RPM spec file added

+
Mon Oct 20 2003:
+

Version 0.3 released; changes include: documentation update, build fixes, RPM spec file added, added new function int daemon_pid_file_kill_wait().

Thu July 10 2003:
-

Version 0.2 released; changes include: ugly umask error fix, documentation update

+

Version 0.2 released; changes include: ugly umask error fix, documentation update

Mon July 7 2003:
-

Version 0.1 released

+

Version 0.1 released

Overview

@@ -73,12 +73,11 @@ daemons. It consists of the following parts:

available. It is not that simple to get it done right and code duplication cannot be a goal.

-

libdaemon is currently used by ifplugd.

+

libdaemon is currently used by ifplugd, waproamd and aeswepd.

Status

-

Version 0.1 is feature complete.

+

Version @PACKAGE_VERSION@ is feature complete.

Documentation

@@ -107,12 +106,14 @@ compilation and make install (as root) for installation of

Download

-

The newest release is always available from http://www.stud.uni-hamburg.de/~lennart/projects/libdaemon/

+

The newest release is always available from @PACKAGE_URL@

+ +

The current release is @PACKAGE_VERSION@

-

The current release is @PACKAGE_VERSION@

+

Get libdaemon's development sources from the Subversion repository.


-
Lennart Poettering <mzyvoqnrzba [at] itaparica.org>, July 2003
+
Lennart Poettering <mzyvoqnrzba [at] itaparica.org>, October 2003
$Id$
diff --git a/doc/style.css b/doc/style.css index 2535ff1..e14ba7c 100644 --- a/doc/style.css +++ b/doc/style.css @@ -1,4 +1,23 @@ /* $Id$ */ + +/*** + * This file is part of libdaemon. + * + * libdaemon is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * libdaemon is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libdaemon; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + ***/ + body { color: black; background-color: white; margin: 0.5cm; } a:link, a:visited { color: #900000; } p { margin-left: 0.5cm; margin-right: 0.5cm; } diff --git a/examples/testd.c b/examples/testd.c index 12b2940..ec5f690 100644 --- a/examples/testd.c +++ b/examples/testd.c @@ -38,7 +38,13 @@ int main(int argc, char *argv[]) { int ret; /* Kill daemon with SIGINT */ + + /* Check if the new function daemon_pid_file_kill_wait() is available, if it is, use it. */ +#ifdef DAEMON_PID_FILE_KILL_WAIT_AVAILABLE + if ((ret = daemon_pid_file_kill_wait(SIGINT, 5)) < 0) +#else if ((ret = daemon_pid_file_kill(SIGINT)) < 0) +#endif daemon_log(LOG_WARNING, "Failed to kill daemon"); return ret < 0 ? 1 : 0; @@ -70,6 +76,7 @@ int main(int argc, char *argv[]) { return 255; } + daemon_log(ret != 0 ? LOG_ERR : LOG_INFO, "Daemon returned %i as return value.", ret); return ret; } else { /* The daemon */ diff --git a/src/Makefile.am b/src/Makefile.am index 129660f..c2719ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,3 +27,4 @@ libdaemon_la_SOURCES = \ dnonblock.c dnonblock.h \ dpid.c dpid.h +libdaemon_la_LDFLAGS = -version-info 1:0:1 diff --git a/src/dpid.c b/src/dpid.c index 6d91cae..6731573 100644 --- a/src/dpid.c +++ b/src/dpid.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "dpid.h" #include "dlog.h" @@ -89,6 +90,36 @@ int daemon_pid_file_kill(int s) { return 0; } +int daemon_pid_file_kill_wait(int s, int m) { + pid_t pid; + time_t t; + + if ((pid = daemon_pid_file_is_running()) < 0) + return -1; + + if (kill(pid, s) < 0) + return -1; + + t = time(NULL) + m; + + for (;;) { + int r; + struct timeval tv = { 0, 100000 }; + + if (time(NULL) > t) + return -1; + + if ((r = kill(pid, 0)) < 0 && errno != ESRCH) + return -1; + + if (r) + return 0; + + if (select(0, NULL, NULL, NULL, &tv) < 0) + return -1; + } +} + int daemon_pid_file_create(void) { const char *fn; FILE *f; diff --git a/src/dpid.h b/src/dpid.h index 8dde464..9812ad9 100644 --- a/src/dpid.h +++ b/src/dpid.h @@ -70,4 +70,18 @@ pid_t daemon_pid_file_is_running(void); */ int daemon_pid_file_kill(int s); +/** If this variable is defined to 1 iff daemon_pid_file_kill_wait() is supported.*/ +#define DAEMON_PID_FILE_KILL_WAIT_AVAILABLE 1 + +/** Similar to daemon_pid_file_kill() but waits until the process + * died. This functions is new in libdaemon 0.3. The macro + * DAEMON_PID_FILE_KILL_WAIT_AVAILABLE is defined iff libdaemon + * supports this function. + * + * @param s The signal to send + * @param m Seconds to wait at maximum + * @return zero on success, nonzero on failure (timeout condition is considered a failure) + */ +int daemon_pid_file_kill_wait(int s, int m); + #endif -- cgit