[pkg-java] r3323 - in tags/commons-daemon: .
1.0.2~svn20061127-5/debian 1.0.2~svn20061127-5/src/native/unix/man
1.0.2~svn20061127-5/src/native/unix/native
Marcus Better
marcusb-guest at alioth.debian.org
Tue Apr 24 12:45:13 UTC 2007
Author: marcusb-guest
Date: 2007-04-24 12:45:13 +0000 (Tue, 24 Apr 2007)
New Revision: 3323
Added:
tags/commons-daemon/1.0.2~svn20061127-5/
tags/commons-daemon/1.0.2~svn20061127-5/debian/changelog
tags/commons-daemon/1.0.2~svn20061127-5/debian/control
tags/commons-daemon/1.0.2~svn20061127-5/debian/rules
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/man/jsvc.1.xml
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/debug.c
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/jsvc-unix.c
Removed:
tags/commons-daemon/1.0.2~svn20061127-5/debian/changelog
tags/commons-daemon/1.0.2~svn20061127-5/debian/control
tags/commons-daemon/1.0.2~svn20061127-5/debian/rules
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/man/jsvc.1.xml
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/debug.c
tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/jsvc-unix.c
Log:
Tag release.
Copied: tags/commons-daemon/1.0.2~svn20061127-5 (from rev 3302, trunk/commons-daemon)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/debian/changelog
===================================================================
--- trunk/commons-daemon/debian/changelog 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/debian/changelog 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,115 +0,0 @@
-commons-daemon (1.0.2~svn20061127-5~test1) unstable; urgency=low
-
- * jsvc can now redirect daemon output to syslog. (Closes: #402878)
- * Added support for the ppc64 architecture. (Closes: #404704)
- * Don't use included config.sub and config.guess.
-
- -- Marcus Better <marcus at better.se> Wed, 13 Dec 2006 15:09:58 +0100
-
-commons-daemon (1.0.2~svn20061127-4) unstable; urgency=low
-
- * Apparently buildds don't grok Build-Depends-Indep. Moved to
- Build-Depends as a workaround.
-
- -- Marcus Better <marcus at better.se> Mon, 4 Dec 2006 14:29:08 +0100
-
-commons-daemon (1.0.2~svn20061127-3) unstable; urgency=low
-
- * Build-depend on java-gcj-compat-dev instead of Build-depend-indep.
-
- -- Marcus Better <marcus at better.se> Mon, 4 Dec 2006 12:50:35 +0100
-
-commons-daemon (1.0.2~svn20061127-2) unstable; urgency=low
-
- * Build-depend on autoconf instead of Build-depend-indep.
-
- -- Marcus Better <marcus at better.se> Thu, 30 Nov 2006 09:39:54 +0100
-
-commons-daemon (1.0.2~svn20061127-1) unstable; urgency=low
-
- * Support the arm, hppa, ia64, m68k, mipsel, and s390
- architectures. (Closes: #307853)
- * Don't include irrelevant README. (Closes: #394169)
- * The jsvc-dev package is no longer built as it's not useful.
- * debian/control:
- - Fix build deps: remove libxerces2-java and libjaxp1.2-java, add autoconf
- and docbook-to-man.
- - Clean up package descriptions.
- * debian/rules:
- - Get rid of CDBS.
- - Pass correct host options to autoconf.
-
- -- Marcus Better <marcus at better.se> Tue, 28 Nov 2006 13:49:20 +0100
-
-commons-daemon (1.0.1-3) unstable; urgency=low
-
- * Apply a patch to support ppc64 arch, thanks to Andreas Jochens
- (closes: #361831)
-
- -- Arnaud Vandyck <avdyk at debian.org> Mon, 3 Jul 2006 11:04:55 +0200
-
-commons-daemon (1.0.1-2) unstable; urgency=low
-
- * (Builds-)Depends on java-gcj-compat(-dev) instead of kaffe(-dev)
- (Closes: #358343).
- * Update Standards-Version to 3.7.2.
-
- -- Michael Koch <konqueror at gmx.de> Sat, 1 Jul 2006 15:56:17 +0000
-
-commons-daemon (1.0.1-1) unstable; urgency=low
-
- * New upstream release
- + updated manpage for new options
- + amd64 now supported
- (I will leave 307853 open until all debian platforms are supported)
- * Patch from upstream CVS to fix invalid execve() usage (closes: #314937)
- * libant1.6-java to ant transition (closes: #326436)
- * Added autotools-dev to let cdbs update the config.guess/sub
- * Standards-Version 3.6.2 (no changes)
-
- * Upload sponsored by XXX
-
- -- Wolfgang Baer <WBaer at gmx.de> Sat, 10 Sep 2005 17:45:46 +0200
-
-commons-daemon (1.0-5) unstable; urgency=low
-
- * upload with the sources.
- * Build with free tools now, therefore buildable on all
- architectures and a jsvc binary should be provided (closes: #286871)
- * Move to main as built with free tools
- * Shortened and clarified description (closes: #279752)
-
- -- Arnaud Vandyck <avdyk at debian.org> Sun, 10 Apr 2005 23:31:38 +0200
-
-commons-daemon (1.0-4) unstable; urgency=low
-
- * Build with free tools now, therefore buildable on all
- architectures and a jsvc binary should be provided (closes: #286871)
- * Moved configure/build of jsvc binary from install/jsvc target to the
- common-configure-arch and common-build-arch targets
- * Move to main as built with free tools
- * Shortened and clarified description (closes: #279752)
- * Build javadoc api and include daemons.html into documentation
- (Removed patch 01_dist_without_javadoc.patch)
- * avdyk: added Wolfgang to the uploaders
-
- -- Wolfgang Baer <WBaer at gmx.de> Fri, 12 Nov 2004 17:48:04 +0100
-
-commons-daemon (1.0-3) unstable; urgency=low
-
- * changed build-dep-indep to build-dep (closes: #280933).
-
- -- Arnaud Vandyck <avdyk at debian.org> Fri, 12 Nov 2004 17:48:04 +0100
-
-commons-daemon (1.0-2) unstable; urgency=low
-
- * improved description for jsvc-dev.
-
- -- Arnaud Vandyck <avdyk at debian.org> Fri, 29 Oct 2004 11:57:53 +0200
-
-commons-daemon (1.0-1) unstable; urgency=low
-
- * Initial Release.
-
- -- Arnaud Vandyck <avdyk at debian.org> Sat, 9 Oct 2004 17:51:44 +0200
-
Copied: tags/commons-daemon/1.0.2~svn20061127-5/debian/changelog (from rev 3321, trunk/commons-daemon/debian/changelog)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/debian/control
===================================================================
--- trunk/commons-daemon/debian/control 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/debian/control 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,38 +0,0 @@
-Source: commons-daemon
-Section: libs
-Priority: optional
-Maintainer: Debian Java Maintainers <pkg-java-maintainers at lists.alioth.debian.org>
-Uploaders: Arnaud Vandyck <avdyk at debian.org>, Wolfgang Baer <WBaer at gmx.de>, Michael Koch <konqueror at gmx.de>, Marcus Better <marcus at better.se>
-Build-Depends: debhelper (>= 5), autoconf, autotools-dev, java-gcj-compat-dev, xsltproc, docbook-xsl, ant
-Build-Conflicts: autoconf2.13
-Standards-Version: 3.7.2
-XS-Vcs-Svn: svn://svn.debian.org/pkg-java/trunk/commons-daemon
-XS-Vcs-Browse: http://svn.debian.org/wsvn/pkg-java/trunk/commons-daemon/
-
-Package: libcommons-daemon-java
-Architecture: all
-Depends: java-gcj-compat | java1-runtime | java2-runtime
-Suggests: java-virtual-machine
-Recommends: jsvc
-Description: library to launch Java applications as daemons
- The Daemon package from Jakarta Commons can be used to implement Java
- applications which can be launched as daemons. For example the
- program will be notified about a shutdown so that it can perform
- cleanup tasks before its process of execution is destroyed by the
- operation system.
- .
- This package contains the java library. You will also need the actual
- binary for your architecture which is provided by the jsvc package.
- .
- Homepage: http://jakarta.apache.org/commons/daemon/
-
-Package: jsvc
-Section: devel
-Architecture: any
-Depends: ${shlibs:Depends}, libcommons-daemon-java
-Description: wrapper to launch Java applications as daemons
- This is the native application for launching Java applications
- implementing certain interfaces from the libcommons-daemon-java
- package as daemons.
- .
- Homepage: http://jakarta.apache.org/commons/daemon/
Copied: tags/commons-daemon/1.0.2~svn20061127-5/debian/control (from rev 3303, trunk/commons-daemon/debian/control)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/debian/rules
===================================================================
--- trunk/commons-daemon/debian/rules 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/debian/rules 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,121 +0,0 @@
-#!/usr/bin/make -f
-
-JAVA_HOME := /usr/lib/jvm/java-gcj
-DEB_JARS_BASE := /usr/share/java
-JAVACMD := $(JAVA_HOME)/bin/java
-
-DEB_JARS := ant ant-launcher
-
-DEB_CLASSPATH = $(shell for jar in $(DEB_JARS); do \
- if [ -f "$$jar" ]; then echo -n "$${jar}:"; fi; \
- if [ -f "$$jar".jar ]; then echo -n "$${jar}.jar:"; fi; \
- if [ -f $(DEB_JARS_BASE)/"$$jar" ]; then echo -n "$(DEB_JARS_BASE)/$${jar}:"; fi; \
- if [ -f $(DEB_JARS_BASE)/"$$jar".jar ]; then echo -n "$(DEB_JARS_BASE)/$${jar}.jar:"; fi; \
- done; \
- if [ -f "$(JAVA_HOME)/lib/tools.jar" ]; then echo -n "$(JAVA_HOME)/lib/tools.jar"; fi)
-
-ANT_INVOKE := $(JAVACMD) -classpath $(DEB_CLASSPATH) \
- org.apache.tools.ant.Main $(ANT_ARGS)
-
-MAN_STYLESHEET := /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
-XSLTPROC := xsltproc --nonet
-
-PKGNAME := commons-daemon
-INSTALLDIR := $(CURDIR)/debian/lib$(PKGNAME)-java
-JAVALIBDIR := $(INSTALLDIR)/usr/share/java
-DOCDIR := $(INSTALLDIR)/usr/share/doc/lib$(PKGNAME)-java
-VERSION := $(shell head -1 debian/changelog | cut -f2 -d\( | cut -f1 -d\) | cut -f1 -d\- | cut -f1 -d\~)
-
-NATIVE_SRC := src/native/unix
-
-export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
-export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
-ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
- confflags += --build $(DEB_HOST_GNU_TYPE)
-else
- confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
-endif
-
-$(NATIVE_SRC)/configure: $(NATIVE_SRC)/configure.in
- cd $(NATIVE_SRC); autoconf
-
-config-stamp: $(NATIVE_SRC)/configure
- dh_testdir
- cd $(NATIVE_SRC); touch install-sh; \
- ./configure $(confflags) --with-java=$(JAVA_HOME)
- touch config-stamp
-
-build: build-arch build-indep
-
-build-arch: build-arch-stamp
-build-arch-stamp: config-stamp
- dh_testdir
- $(MAKE) -C $(NATIVE_SRC)
- $(XSLTPROC) $(MAN_STYLESHEET) $(NATIVE_SRC)/man/jsvc.1.xml
- touch build-arch-stamp
-
-build-indep: build-indep-stamp
-build-indep-stamp:
- dh_testdir
- $(ANT_INVOKE)
- touch build-indep-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f *-stamp jsvc.1
- rm -rf target dist
- -(cd src/native/unix ; make clean)
- -rm -f src/native/unix/config.{log,status}
- -rm -f src/native/unix/{Makefile,Makedefs,native/Makefile,install-sh}
- cp -f /usr/share/misc/config.sub $(NATIVE_SRC)/config.sub
- cp -f /usr/share/misc/config.guess $(NATIVE_SRC)/config.guess
- dh_clean
-
-install: install-arch install-indep
-
-install-indep: build-indep
- dh_testdir
- dh_testroot
- dh_clean -k -i
- dh_installdirs -i
- dh_install -i
- install -m 644 dist/$(PKGNAME).jar $(JAVALIBDIR)/$(PKGNAME)-$(VERSION).jar
- ln -s $(PKGNAME)-$(VERSION).jar $(JAVALIBDIR)/$(PKGNAME).jar
- dh_installdocs -i
- mv $(DOCDIR)/api $(DOCDIR)/apidocs
-
-install-arch: build-arch
- dh_testdir
- dh_testroot
- dh_clean -k -a
- dh_installdirs -a
- dh_install -a
- dh_installdocs -a
- dh_installman -a
-
-binary-common:
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
- dh_installdeb
-
-binary-arch: install-arch
- $(MAKE) -f debian/rules DH_OPTIONS=-a binary-common
- dh_shlibdeps -a
- dh_gencontrol -a
- dh_md5sums -a
- dh_builddeb -a
-
-binary-indep: install-indep
- $(MAKE) -f debian/rules DH_OPTIONS=-i binary-common
- dh_gencontrol -i
- dh_md5sums -i
- dh_builddeb -i
-
-binary: binary-indep binary-arch
-.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install install-arch install-indep
Copied: tags/commons-daemon/1.0.2~svn20061127-5/debian/rules (from rev 3309, trunk/commons-daemon/debian/rules)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/man/jsvc.1.xml
===================================================================
--- trunk/commons-daemon/src/native/unix/man/jsvc.1.xml 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/man/jsvc.1.xml 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,172 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
-<refentry id='jsvc1'>
- <refmeta>
- <refentrytitle>JSVC</refentrytitle>
- <manvolnum>1</manvolnum>
- <refmiscinfo class='date'>May 2005</refmiscinfo>
- <refmiscinfo class='source'>Jsvc version 1.0.1</refmiscinfo>
- <refmiscinfo class='manual'>Jakarta project</refmiscinfo>
- </refmeta>
- <refnamediv id='name'>
- <refname>jsvc</refname>
- <refpurpose>application to launch java daemon</refpurpose>
- </refnamediv>
- <!-- body begins here -->
- <refsynopsisdiv id='synopsis'>
- <cmdsynopsis>
- <command>jsvc</command>
- <arg choice='opt'>-jvm <replaceable>JVM name</replaceable></arg>
- <arg choice='opt'>-classpath <replaceable>path</replaceable></arg>
- <arg choice='opt'>-cp <replaceable>path</replaceable></arg>
- <arg choice='opt'>-home <replaceable>directory</replaceable></arg>
- <arg choice='opt'>-version</arg>
- <arg choice='opt'>-help</arg>
- <arg choice='opt'>-?</arg>
- <arg choice='opt'>-nodetach</arg>
- <arg choice='opt'>-debug</arg>
- <arg choice='opt'>-check</arg>
- <arg choice='opt'>-user <replaceable>user</replaceable></arg>
- <arg choice='opt'>-wait <replaceable>waittime</replaceable></arg>
- <arg choice='opt'>-stop</arg>
- <arg choice='opt'>-verbose<replaceable>:class|gc|jni</replaceable></arg>
- <arg choice='opt'>-outfile <replaceable>/full/path/to/file</replaceable></arg>
- <arg choice='opt'>-errfile <replaceable>/full/path/to/file</replaceable></arg>
- <arg choice='opt'>-pidfile <replaceable>/full/path/to/file</replaceable></arg>
- <arg choice='opt'>-Dproperty=<replaceable>value</replaceable></arg>
- <arg choice='opt'>-X<replaceable>option</replaceable></arg>
- <!-- end of the new arguments -->
- </cmdsynopsis>
- </refsynopsisdiv>
- <refsect1 id="description">
- <title>DESCRIPTION</title>
- <para><command>jsvc</command> executes <emphasis remap="I">classfile</emphasis>
- that implements a Daemon interface.</para>
- </refsect1>
-
- <refsect1 id="options">
- <title>OPTIONS</title>
-
- <variablelist remap="TP">
- <varlistentry>
- <term><option>-jvm</option> JVM name</term>
- <listitem>
- <para>use a specific Java Virtual Machine.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-cp/ -classpath</option> directory and zip/jar
- files</term>
- <listitem>
- <para>set search path for service classes and resouces</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-home</option> directory</term>
- <listitem>
- <para>set the path of your JDK or JRE installation (or set
- the JAVA_HOME environment variable)
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-version</option></term>
- <listitem>
- <para>show the current Java environment version (to check
- correctness of -home and -jvm. Implies -nodetach)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-help</option></term>
- <listitem>
- <para>show this help page (implies -nodetach)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-nodetach</option></term>
- <listitem>
- <para>don't detach from parent process and become a daemon</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-debug</option></term>
- <listitem>
- <para>verbosely print debugging information</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-check</option></term>
- <listitem>
- <para>only check service (implies -nodetach)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-stop</option></term>
- <listitem>
- <para>stop the service using the file given in the -pidfile option</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-wait</option> waittime</term>
- <listitem>
- <para>wait up to waittime seconds for the service to start
- waittime should multiple of 10 (min=10)
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-user</option> user</term>
- <listitem>
- <para>user used to run the daemon (defaults to current user)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-verbose[:class|gc|jni]</option></term>
- <listitem>
- <para>enable verbose output</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-outfile</option> /full/path/to/file</term>
- <listitem>
- <para>Location for output from stdout (defaults to /dev/null). Use
- the value '&2' to simulate '1>&2'</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-errfile</option> /full/path/to/file</term>
- <listitem>
- <para>Location for output from stderr (defaults to /dev/null). Use
- the value '&1' to simulate '2>&1'</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-pidfile</option> /full/path/to/file</term>
- <listitem>
- <para>Location for output from the file containing the pid of jsvc
- (defaults to /var/run/jsvc.pid)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-D</option><name>=<value></term>
- <listitem>
- <para>set a Java system property</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><option>-X</option><option></term>
- <listitem>
- <para>set Virtual Machine specific option</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1 id='author'><title>AUTHOR</title>
- <para>JSVC is part of the Jakarta Commons Daemon project. Authors are
- Jean-Frederic Clere, Remy Maucherat, Yoav Shapira, Bill Barker. JSVC is
- under the Apache License Version 2.0.</para>
- </refsect1>
-
-</refentry>
Copied: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/man/jsvc.1.xml (from rev 3310, trunk/commons-daemon/src/native/unix/man/jsvc.1.xml)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/debug.c
===================================================================
--- trunk/commons-daemon/src/native/unix/native/debug.c 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/debug.c 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,70 +0,0 @@
-/*
- Copyright 2001-2004 The Apache Software Foundation.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-/* @version $Id: debug.c 165119 2005-04-28 09:00:08Z jfclere $ */
-#include "jsvc.h"
-#include <sys/types.h>
-#include <unistd.h>
-#include <time.h>
-
-/* Wether debug is enabled or not */
-bool log_debug_flag = false;
-
-/* The name of the jsvc binary. */
-char *log_prog = "jsvc";
-
-/* Dump a debug message to stderr */
-void log_debug(const char *fmt, ...) {
- va_list ap;
- time_t now;
- struct tm *nowtm;
- char buff[80];
-
- if (log_debug_flag==false) return;
- if (fmt==NULL) return;
-
- now = time(NULL);
- nowtm = localtime(&now);
- strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
-
- va_start(ap,fmt);
- fprintf(stderr,"%s %d %s debug: ", buff, getpid(), log_prog);
- vfprintf(stderr,fmt,ap);
- fprintf(stderr,"\n");
- fflush(stderr);
- va_end(ap);
-}
-
-/* Dump an error message to stderr */
-void log_error(const char *fmt, ...) {
- va_list ap;
- time_t now;
- struct tm *nowtm;
- char buff[80];
-
- if (fmt==NULL) return;
-
- now = time(NULL);
- nowtm = localtime(&now);
- strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
-
- va_start(ap,fmt);
- fprintf(stderr,"%s %d %s error: ", buff, getpid(), log_prog);
- vfprintf(stderr,fmt,ap);
- fprintf(stderr,"\n");
- fflush(stderr);
- va_end(ap);
-}
-
Copied: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/debug.c (from rev 3311, trunk/commons-daemon/src/native/unix/native/debug.c)
Deleted: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/jsvc-unix.c
===================================================================
--- trunk/commons-daemon/src/native/unix/native/jsvc-unix.c 2007-04-22 07:25:11 UTC (rev 3302)
+++ tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/jsvc-unix.c 2007-04-24 12:45:13 UTC (rev 3323)
@@ -1,926 +0,0 @@
-/*
- Copyright 2001-2004 The Apache Software Foundation.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-/* @version $Id: jsvc-unix.c 397516 2006-04-27 10:36:27Z jfclere $ */
-#include "jsvc.h"
-
-#include <signal.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <pwd.h>
-#include <grp.h>
-#include <syslog.h>
-#include <errno.h>
-#ifdef OS_LINUX
-#include <sys/prctl.h>
-#include <sys/syscall.h>
-#define _LINUX_FS_H
-#include <linux/capability.h>
-#endif
-#include <time.h>
-
-#ifdef OS_CYGWIN
-#include <sys/fcntl.h>
-#define F_ULOCK 0 /* Unlock a previously locked region */
-#define F_LOCK 1 /* Lock a region for exclusive use */
-#endif
-
-extern char **environ;
-
-static mode_t envmask; /* mask to create the files */
-
-pid_t controlled=0; /* the son process pid */
-pid_t logger=0; /* the logger process pid */
-static bool stopping=false;
-static bool doreload=false;
-static void (*handler_int)(int)=NULL;
-static void (*handler_hup)(int)=NULL;
-static void (*handler_trm)(int)=NULL;
-
-#ifdef OS_CYGWIN
-/*
- * File locking routine
- */
-static int lockf(int fildes, int function, off_t size)
-{
- struct flock buf;
-
- switch (function) {
- case F_LOCK:
- buf.l_type = F_WRLCK;
- break;
- case F_ULOCK:
- buf.l_type = F_UNLCK;
- break;
- default:
- return -1;
- }
- buf.l_whence = 0;
- buf.l_start = 0;
- buf.l_len = size;
-
- return fcntl(fildes, F_SETLK, &buf);
-}
-
-#endif
-
-static void handler(int sig) {
- switch (sig) {
- case SIGTERM: {
- log_debug("Caught SIGTERM: Scheduling a shutdown");
- if (stopping==true) {
- log_error("Shutdown or reload already scheduled");
- } else {
- stopping=true;
- }
- break;
- }
-
- case SIGINT: {
- log_debug("Caught SIGINT: Scheduling a shutdown");
- if (stopping==true) {
- log_error("Shutdown or reload already scheduled");
- } else {
- stopping=true;
- }
- break;
- }
-
- case SIGHUP: {
- log_debug("Caught SIGHUP: Scheduling a reload");
- if (stopping==true) {
- log_error("Shutdown or reload already scheduled");
- } else {
- stopping=true;
- doreload=true;
- }
- break;
- }
-
- default: {
- log_debug("Caught unknown signal %d",sig);
- break;
- }
- }
-}
-
-/* user and group */
-static int set_user_group(char *user, int uid, int gid)
-{
- if (user!=NULL) {
- if (setgid(gid)!=0) {
- log_error("Cannot set group id for user '%s'",user);
- return(-1);
- }
- if (initgroups(user, gid)!=0) {
- if (getuid()!= uid) {
- log_error("Cannot set supplement group list for user '%s'",user);
- return(-1);
- } else
- log_debug("Cannot set supplement group list for user '%s'",user);
- }
- if (getuid() == uid) {
- log_debug("No need to change user to '%s'!",user);
- return(0);
- }
- if (setuid(uid)!=0) {
- log_error("Cannot set user id for user '%s'",user);
- return(-1);
- }
- log_debug("user changed to '%s'",user);
- }
- return(0);
-}
-/* Set linux capability, user and group */
-#ifdef OS_LINUX
-/* CAPSALL is to allow to read/write at any location */
-#define CAPSALL (1 << CAP_NET_BIND_SERVICE)+ \
- (1 << CAP_SETUID)+ \
- (1 << CAP_SETGID)+ \
- (1 << CAP_DAC_READ_SEARCH)+ \
- (1 << CAP_DAC_OVERRIDE)
-#define CAPSMAX (1 << CAP_NET_BIND_SERVICE)+ \
- (1 << CAP_DAC_READ_SEARCH)+ \
- (1 << CAP_DAC_OVERRIDE)
-/* That a more reasonable configuration */
-#define CAPS (1 << CAP_NET_BIND_SERVICE)+ \
- (1 << CAP_SETUID)+ \
- (1 << CAP_SETGID)
-/* probably the only one Java could use */
-#define CAPSMIN (1 << CAP_NET_BIND_SERVICE)
-static int set_caps(int caps)
-{
- struct __user_cap_header_struct caphead;
- struct __user_cap_data_struct cap;
-
- memset(&caphead, 0, sizeof caphead);
- caphead.version = _LINUX_CAPABILITY_VERSION;
- caphead.pid = 0;
- memset(&cap, 0, sizeof cap);
- cap.effective = caps;
- cap.permitted = caps;
- cap.inheritable = caps;
- if (syscall(__NR_capset, &caphead, &cap) < 0) {
- log_error("syscall failed in set_caps");
- return(-1);
- }
- return(0);
-}
-static int linuxset_user_group(char *user, int uid, int gid)
-{
- /* set capabilities enough for binding port 80 setuid/getuid */
- if (set_caps(CAPS)!=0) {
- if (getuid()!= uid) {
- log_error("set_caps(CAPS) failed");
- return(-1);
- }
- log_debug("set_caps(CAPS) failed");
- }
-
- /* make sure they are kept after setuid */
- if (prctl(PR_SET_KEEPCAPS,1,0,0,0) < 0) {
- log_error("prctl failed in linuxset_user_group");
- return(-1);
- }
-
- /* set setuid/getuid */
- if (set_user_group(user,uid,gid)!=0) {
- log_error("set_user_group failed in linuxset_user_group");
- return(-1);
- }
-
- /* set capability to binding port 80 read conf */
- if (set_caps(CAPSMIN)!=0) {
- if (getuid()!= uid) {
- log_error("set_caps(CAPSMIN) failed");
- return(-1);
- }
- log_debug("set_caps(CAPSMIN) failed");
- }
-
- return(0);
-}
-#endif
-
-
-static bool checkuser(char *user, uid_t *uid, gid_t *gid) {
- struct passwd *pwds=NULL;
- int status=0;
- pid_t pid=0;
-
- /* Do we actually _have_ to switch user? */
- if (user==NULL) return(true);
-
- pwds=getpwnam(user);
- if (pwds==NULL) {
- log_error("Invalid user name '%s' specified",user);
- return(false);
- }
-
- *uid=pwds->pw_uid;
- *gid=pwds->pw_gid;
-
- /* Validate the user name in another process */
- pid=fork();
- if (pid==-1) {
- log_error("Cannot validate user name");
- return(false);
- }
-
- /* If we're in the child process, let's validate */
- if (pid==0) {
- if (set_user_group(user,*uid,*gid)!=0)
- exit(1);
- /* If we got here we switched user/group */
- exit(0);
- }
-
- while (waitpid(pid,&status,0)!=pid);
-
- /* The child must have exited cleanly */
- if (WIFEXITED(status)) {
- status=WEXITSTATUS(status);
-
- /* If the child got out with 0 the user is ok */
- if (status==0) {
- log_debug("User '%s' validated",user);
- return(true);
- }
- }
-
- log_error("Error validating user '%s'",user);
- return(false);
-}
-
-#ifdef OS_CYGWIN
-static void cygwincontroller() {
- raise(SIGTERM);
-}
-#endif
-static void controller(int sig) {
- switch (sig) {
- case SIGTERM:
- case SIGINT:
- case SIGHUP:
- log_debug("Forwarding signal %d to process %d",sig,controlled);
- kill(controlled,sig);
- signal(sig,controller);
- break;
- default:
- log_debug("Caught unknown signal %d",sig);
- break;
- }
-}
-/*
- * Return the address of the current signal handler and set the new one.
- */
-static void * signal_set(int sig, void * newHandler) {
- void *hand;
-
- hand=signal(sig,newHandler);
-#ifdef SIG_ERR
- if (hand==SIG_ERR)
- hand=NULL;
-#endif
- if (hand==handler || hand==controller)
- hand=NULL;
- return(hand);
-}
-
-/*
- * Check pid and if still running
- */
-
-static int check_pid(arg_data *args) {
- int fd;
- FILE *pidf;
- char buff[80];
- pid_t pidn=getpid();
- int i,pid;
-
- fd = open(args->pidf,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);
- if (fd<0) {
- log_error("Cannot open PID file %s, PID is %d",args->pidf,pidn);
- return(-1);
- } else {
- lockf(fd,F_LOCK,0);
- i = read(fd,buff,sizeof(buff));
- if (i>0) {
- buff[i] = '\0';
- pid = atoi(buff);
- if (kill(pid, 0)==0) {
- log_error("Still running according to PID file %s, PID is %d",args->pidf,pid);
- lockf(fd,F_ULOCK,0);
- close(fd);
- return(122);
- }
- }
-
- /* skip writing the pid file if version or check */
- if (args->vers!=true && args->chck!=true) {
- lseek(fd, SEEK_SET, 0);
- pidf = fdopen(fd,"r+");
- fprintf(pidf,"%d\n",(int)getpid());
- fflush(pidf);
- lockf(fd,F_ULOCK,0);
- fclose(pidf);
- close(fd);
- } else {
- lockf(fd,F_ULOCK,0);
- close(fd);
- }
- }
- return(0);
-}
-
-/*
- * read the pid from the pidfile
- */
-static int get_pidf(arg_data *args) {
- int fd;
- int i;
- char buff[80];
-
- fd = open(args->pidf, O_RDONLY, 0);
- log_debug("get_pidf: %d in %s", fd, args->pidf);
- if (fd<0)
- return(-1); /* something has gone wrong the JVM has stopped */
- lockf(fd,F_LOCK,0);
- i = read(fd,buff,sizeof(buff));
- lockf(fd,F_ULOCK,0);
- close(fd);
- if (i>0) {
- buff[i] = '\0';
- i = atoi(buff);
- log_debug("get_pidf: pid %d", i);
- if (kill(i, 0)==0)
- return(i);
- }
- return(-1);
-}
-
-/*
- * Check temporatory file created by controller
- * /tmp/pid.jsvc_up
- * Notes:
- * we fork several times
- * 1 - to be a daemon before the setsid(), the son is the controler process.
- * 2 - to start the JVM in the son process. (whose pid is stored in pidfile).
- */
-static int check_tmp_file(arg_data *args) {
- int pid;
- char buff[80];
- int fd;
- pid = get_pidf(args);
- if (pid<0)
- return(-1);
- sprintf(buff,"/tmp/%d.jsvc_up", pid);
- log_debug("check_tmp_file: %s", buff);
- fd = open(buff, O_RDONLY);
- if (fd<0)
- return(-1);
- close(fd);
- return(0);
-}
-static void create_tmp_file(arg_data *args) {
- char buff[80];
- int fd;
- sprintf(buff,"/tmp/%d.jsvc_up", (int) getpid());
- log_debug("create_tmp_file: %s", buff);
- fd = open(buff, O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);
- if (fd<0)
- return;
- close(fd);
-}
-static void remove_tmp_file(arg_data *args) {
- char buff[80];
- sprintf(buff,"/tmp/%d.jsvc_up", (int) getpid());
- log_debug("remove_tmp_file: %s", buff);
- unlink(buff);
-}
-
-/*
- * wait until jsvc create the I am ready file
- * pid is the controller and args->pidf the JVM itself.
- */
-static int wait_child(arg_data *args, int pid) {
- int count=10;
- bool havejvm=false;
- int fd;
- char buff[80];
- int i, status, waittime;
- log_debug("wait_child %d", pid);
- waittime = args->wait/10;
- if (waittime>10) {
- count = waittime;
- waittime = 10;
- }
- while (count>0) {
- sleep(1);
- /* check if the controler is still running */
- if (waitpid(pid,&status,WNOHANG)==pid) {
- if (WIFEXITED(status))
- return(WEXITSTATUS(status));
- else
- return(1);
- }
-
- /* check if the pid file process exists */
- fd = open(args->pidf, O_RDONLY);
- if (fd<0 && havejvm)
- return(1); /* something has gone wrong the JVM has stopped */
- lockf(fd,F_LOCK,0);
- i = read(fd,buff,sizeof(buff));
- lockf(fd,F_ULOCK,0);
- close(fd);
- if (i>0) {
- buff[i] = '\0';
- i = atoi(buff);
- if (kill(i, 0)==0) {
- /* the JVM process has started */
- havejvm=true;
- if (check_tmp_file(args)==0) {
- /* the JVM is started */
- if (waitpid(pid,&status,WNOHANG)==pid) {
- if (WIFEXITED(status))
- return(WEXITSTATUS(status));
- else
- return(1);
- }
- return(0); /* ready JVM started */
- }
- }
- }
- sleep(waittime);
- count--;
- }
- return(1); /* It takes more than the wait time to start, something must be wrong */
-}
-
-/*
- * stop the running jsvc
- */
-static int stop_child(arg_data *args) {
- int pid=get_pidf(args);
- int count=10;
- if (pid>0) {
- /* kill the process and wait until the pidfile has been removed by the controler */
- kill(pid,SIGTERM);
- while (count>0) {
- sleep(6);
- pid=get_pidf(args);
- if (pid<=0)
- return(0); /* JVM has stopped */
- count--;
- }
- }
- return(-1);
-}
-
-/*
- * son process logic.
- */
-
-static int child(arg_data *args, home_data *data, uid_t uid, gid_t gid) {
- int ret=0;
-
- /* check the pid file */
- ret = check_pid(args);
- if (args->vers!=true && args->chck!=true) {
- if (ret==122)
- return(ret);
- if (ret<0)
- return(ret);
- }
-
- /* create a new process group to prevent kill 0 killing the monitor process */
-#if defined(OS_FREEBSD) || defined(OS_DARWIN)
- setpgid(0,0);
-#else
- setpgrp();
-#endif
-
-#ifdef OS_LINUX
- /* setuid()/setgid() only apply the current thread so we must do it now */
- if (linuxset_user_group(args->user,uid,gid)!=0)
- return(4);
-#endif
- /* Initialize the Java VM */
- if (java_init(args,data)!=true) {
- log_debug("java_init failed");
- return(1);
- } else
- log_debug("java_init done");
-
- /* Check wether we need to dump the VM version */
- if (args->vers==true) {
- if (java_version()!=true) {
- return(-1);
- } else return(0);
- }
-
- /* Do we have to do a "check-only" initialization? */
- if (args->chck==true) {
- if (java_check(args)!=true) return(2);
- printf("Service \"%s\" checked successfully\n",args->clas);
- return(0);
- }
-
- /* Load the service */
- if (java_load(args)!=true) {
- log_debug("java_load failed");
- return(3);
- } else
- log_debug("java_load done");
-
- /* Downgrade user */
-#ifdef OS_LINUX
- if (set_caps(0)!=0) {
- log_debug("set_caps (0) failed");
- return(4);
- }
-#else
- if (set_user_group(args->user,uid,gid)!=0)
- return(4);
-#endif
-
- /* Start the service */
- umask(envmask);
- if (java_start()!=true) {
- log_debug("java_start failed");
- return(5);
- } else
- log_debug("java_start done");
-
- /* Install signal handlers */
- handler_hup=signal_set(SIGHUP,handler);
- handler_trm=signal_set(SIGTERM,handler);
- handler_int=signal_set(SIGINT,handler);
- controlled = getpid();
- log_debug("Waiting for a signal to be delivered");
- create_tmp_file(args);
- while (!stopping) {
-#if defined(OSD_POSIX) || defined(HAVE_KAFFEVM)
- java_sleep(60);
- /* pause(); */
-#else
- sleep(60); /* pause() not threadsafe */
-#endif
- }
- remove_tmp_file(args);
- log_debug("Shutdown or reload requested: exiting");
-
- /* Stop the service */
- if (java_stop()!=true) return(6);
-
- if (doreload==true) ret=123;
- else ret=0;
-
- /* Destroy the service */
- java_destroy();
-
- /* Destroy the Java VM */
- if (JVM_destroy(ret)!=true) return(7);
-
- return(ret);
-}
-
-/*
- * freopen close the file first and then open the new file
- * that is not very good if we are try to trace the output
- * note the code assumes that the errors are configuration errors.
- */
-static FILE *loc_freopen(char *outfile, char *mode, FILE *stream)
-{
- FILE *ftest;
- ftest = fopen(outfile,mode);
- if (ftest == NULL) {
- fprintf(stderr,"Unable to redirect to %s\n", outfile);
- return(stream);
- }
- fclose(ftest);
- return(freopen(outfile,mode,stream));
-}
-
-#define LOGBUF_SIZE 1024
-
-/* Read from file descriptors. Log to syslog. */
-static int logger_child (int outpipe, int errpipe, char *procname) {
- fd_set rfds;
- struct timeval tv;
- int retval, n;
- char buf[LOGBUF_SIZE];
-
- buf[LOGBUF_SIZE-1] = 0;
-
- if (outpipe > errpipe) {
- n = outpipe + 1;
- } else {
- n = errpipe + 1;
- }
-
- openlog(procname, LOG_PID, LOG_DAEMON);
-
- while (1) {
- FD_ZERO(&rfds);
- FD_SET(outpipe, &rfds);
- FD_SET(errpipe, &rfds);
- tv.tv_sec = 60;
- tv.tv_usec = 0;
- retval = select(n, &rfds, NULL, NULL, &tv);
- if (retval == -1)
- perror("select()");
- else if (retval) {
- if (FD_ISSET(outpipe, &rfds)) {
- read(outpipe, buf, LOGBUF_SIZE-1);
- syslog(LOG_INFO, "%s", buf);
- }
- if (FD_ISSET(errpipe, &rfds)) {
- read(errpipe, buf, LOGBUF_SIZE-1);
- syslog(LOG_ERR, "%s", buf);
- }
- }
- }
-}
-
-/**
- * Redirect stdin, stdout, stderr.
- */
-static void set_output(char *outfile, char *errfile, char *procname) {
- int out_pipe[2] = {0, 0}, err_pipe[2] = {0, 0}, fork_needed = 0;
-
- freopen("/dev/null", "r", stdin);
- log_debug("redirecting stdout to %s and stderr to %s",outfile,errfile);
-
- /* make sure the debug goes out */
- if (log_debug_flag==true && strcmp(errfile,"/dev/null") == 0)
- return;
-
- /* Handle malicious case here */
- if(strcmp(outfile, "&2") == 0 && strcmp(errfile,"&1") == 0) {
- outfile="/dev/null";
- }
-
- if (strcmp(outfile, "SYSLOG") == 0) {
- /* Send stdout to syslog through a logger process */
- if (pipe(out_pipe) == -1) {
- log_error("cannot create stdout pipe: %s",
- strerror(errno));
- } else {
- fork_needed = 1;
- }
- } else if (strcmp(outfile, "&2") != 0) {
- loc_freopen(outfile, "a", stdout);
- }
-
- if (strcmp(errfile, "SYSLOG") == 0) {
- /* Send stderr to syslog through a logger process */
- if (pipe(err_pipe) == -1) {
- log_error("cannot create stderr pipe: %s",
- strerror(errno));
- } else {
- fork_needed = 1;
- }
- } else if (strcmp(errfile, "&1") != 0) {
- loc_freopen(errfile, "a", stderr);
- } else {
- close(2);
- dup(1);
- }
- if(strcmp(outfile, "&2") == 0) {
- close(1);
- dup(2);
- }
-
- if (fork_needed) {
- pid_t pid = fork();
- if (pid == -1) {
- log_error("cannot create logger process: %s", strerror(errno));
- } else {
- if (pid) {
- if (out_pipe[0] != 0) {
- close(out_pipe[0]);
- if (dup2(out_pipe[1], 1) == -1) {
- log_error("cannot redirect stdout to pipe for syslog: %s",
- strerror(errno));
- }
- }
- if (err_pipe[0] != 0) {
- close(err_pipe[0]);
- if (dup2(err_pipe[1], 2) == -1) {
- log_error("cannot redirect stderr to pipe for syslog: %s",
- strerror(errno));
- }
- }
- } else {
- exit(logger_child(out_pipe[1], err_pipe[1], procname));
- }
- }
- }
-}
-
-int main(int argc, char *argv[]) {
- arg_data *args=NULL;
- home_data *data=NULL;
- int status=0;
- pid_t pid=0;
- uid_t uid=0;
- gid_t gid=0;
- time_t laststart;
-
- /* Parse command line arguments */
- args=arguments(argc,argv);
- if (args==NULL) return(1);
-
- /* Stop running jsvc if required */
- if (args->stop==true)
- return(stop_child(args));
-
- /* Let's check if we can switch user/group IDs */
- if (checkuser(args->user, &uid, &gid)==false) return(1);
-
- /* Retrieve JAVA_HOME layout */
- data=home(args->home);
- if (data==NULL) return(1);
-
- /* Check for help */
- if (args->help==true) {
- help(data);
- return(0);
- }
-
-#if 0
- /* On some UNIX operating systems, we need to REPLACE this current
- process image with another one (thru execve) to allow the correct
- loading of VMs (notably this is for Linux). Set, replace, and go. */
- if (strcmp(argv[0],args->procname)!=0) {
- char *oldpath=getenv("LD_LIBRARY_PATH");
- char *libf=java_library(args,data);
- char *filename;
- char buf[2048];
- int ret;
- char *tmp=NULL;
- char *p1=NULL;
- char *p2=NULL;
-
- /*
- * There is no need to change LD_LIBRARY_PATH
- * if we were not able to find a path to libjvm.so
- * (additionaly a strdup(NULL) cores dump on my machine).
- */
- if (libf!=NULL) {
- p1=strdup(libf);
- tmp=strrchr(p1,'/');
- if (tmp!=NULL) tmp[0]='\0';
-
- p2=strdup(p1);
- tmp=strrchr(p2,'/');
- if (tmp!=NULL) tmp[0]='\0';
-
- if (oldpath==NULL) snprintf(buf,2048,"%s:%s",p1,p2);
- else snprintf(buf,2048,"%s:%s:%s",oldpath,p1,p2);
-
- tmp=strdup(buf);
- setenv("LD_LIBRARY_PATH",tmp,1);
-
- log_debug("Invoking w/ LD_LIBRARY_PATH=%s",getenv("LD_LIBRARY_PATH"));
- }
-
- /* execve needs a full path */
- ret = readlink("/proc/self/exe",buf,sizeof(buf)-1);
- if (ret<=0)
- strcpy(buf,argv[0]);
- else
- buf[ret]='\0';
-
- filename=buf;
-
- argv[0]=args->procname;
- execve(filename,argv,environ);
- log_error("Cannot execute JSVC executor process (%s)",filename);
- return(1);
- }
- log_debug("Running w/ LD_LIBRARY_PATH=%s",getenv("LD_LIBRARY_PATH"));
-#endif /* ifdef OS_LINUX */
-
- /* If we have to detach, let's do it now */
- if (args->dtch==true) {
- pid=fork();
- if (pid==-1) {
- log_error("Cannot detach from parent process");
- return(1);
- }
- /* If we're in the parent process */
- if (pid!=0) {
- if (args->wait>=10)
- return(wait_child(args,pid));
- else
- return(0);
- }
-#ifndef NO_SETSID
- setsid();
-#endif
- }
-
- envmask = umask(0077);
- set_output(args->outfile, args->errfile, args->procname);
-
- /* We have to fork: this process will become the controller and the other
- will be the child */
- while ((pid=fork())!=-1) {
- /* We forked (again), if this is the child, we go on normally */
- if (pid==0) exit(child(args,data,uid,gid));
- laststart = time(NULL);
-
- /* We are in the controller, we have to forward all interesting signals
- to the child, and wait for it to die */
- controlled=pid;
-#ifdef OS_CYGWIN
- SetTerm(cygwincontroller);
-#endif
- signal(SIGHUP,controller);
- signal(SIGTERM,controller);
- signal(SIGINT,controller);
-
- while (waitpid(pid,&status,0)!=pid);
-
- /* The child must have exited cleanly */
- if (WIFEXITED(status)) {
- status=WEXITSTATUS(status);
-
- /* Delete the pid file */
- if (args->vers!=true && args->chck!=true && status!=122)
- unlink(args->pidf);
-
- /* If the child got out with 123 he wants to be restarted */
- /* See java_abort123 (we use this return code to restart when the JVM aborts) */
- if (status==123) {
- log_debug("Reloading service");
- /* prevent looping */
- if (laststart+60>time(NULL)) {
- log_debug("Waiting 60 s to prevent looping");
- sleep(60);
- }
- continue;
- }
- /* If the child got out with 0 he is shutting down */
- if (status==0) {
- log_debug("Service shut down");
- return(0);
- }
- /* Otherwise we don't rerun it */
- log_error("Service exit with a return value of %d",status);
- return(1);
-
- } else {
- if (WIFSIGNALED(status)) {
- log_error("Service killed by signal %d",WTERMSIG(status));
- /* prevent looping */
- if (laststart+60>time(NULL)) {
- log_debug("Waiting 60 s to prevent looping");
- sleep(60);
- }
- continue;
- }
- log_error("Service did not exit cleanly",status);
- return(1);
- }
- }
-
- /* Got out of the loop? A fork() failed then. */
- log_error("Cannot decouple controller/child processes");
- return(1);
-
-}
-
-void main_reload(void) {
- log_debug("Killing self with HUP signal");
- kill(controlled,SIGHUP);
- if (logger != 0) {
- kill(logger,SIGHUP);
- }
-}
-
-void main_shutdown(void) {
- log_debug("Killing self with TERM signal");
- kill(controlled,SIGTERM);
- if (logger != 0) {
- kill(logger,SIGTERM);
- }
-}
Copied: tags/commons-daemon/1.0.2~svn20061127-5/src/native/unix/native/jsvc-unix.c (from rev 3321, trunk/commons-daemon/src/native/unix/native/jsvc-unix.c)
More information about the pkg-java-commits
mailing list