diff options
Diffstat (limited to 'libdaemon')
| -rw-r--r-- | libdaemon/Makefile.am | 13 | ||||
| -rw-r--r-- | libdaemon/daemon.h | 37 | ||||
| -rw-r--r-- | libdaemon/dexec.c | 85 | ||||
| -rw-r--r-- | libdaemon/dexec.h | 43 | ||||
| -rw-r--r-- | libdaemon/dfork.c | 39 | ||||
| -rw-r--r-- | libdaemon/dfork.h | 37 | ||||
| -rw-r--r-- | libdaemon/dlog.c | 45 | ||||
| -rw-r--r-- | libdaemon/dlog.h | 37 | ||||
| -rw-r--r-- | libdaemon/dnonblock.c | 39 | ||||
| -rw-r--r-- | libdaemon/dnonblock.h | 37 | ||||
| -rw-r--r-- | libdaemon/dpid.c | 39 | ||||
| -rw-r--r-- | libdaemon/dpid.h | 37 | ||||
| -rw-r--r-- | libdaemon/dsignal.c | 57 | ||||
| -rw-r--r-- | libdaemon/dsignal.h | 37 | 
14 files changed, 284 insertions, 298 deletions
diff --git a/libdaemon/Makefile.am b/libdaemon/Makefile.am index 6812c3d..11a5305 100644 --- a/libdaemon/Makefile.am +++ b/libdaemon/Makefile.am @@ -1,21 +1,20 @@ -# $Id$ -#  # This file is part of libdaemon.  # +# Copyright 2003-2008 Lennart Poettering +#  # libdaemon is free software; you can redistribute it and/or modify it  # under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of the +# published by the Free Software Foundation, either version 2.1 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  # Lesser General Public License for more details.  #  # You should have received a copy of the GNU Lesser General Public -# License along with libdaemon; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -# USA +# License along with libdaemon. If not, see +# <http://www.gnu.org/licenses/>.  AM_CPPFLAGS='-DLOCALSTATEDIR="$(localstatedir)"' diff --git a/libdaemon/daemon.h b/libdaemon/daemon.h index 9c66d34..18eb5bf 100644 --- a/libdaemon/daemon.h +++ b/libdaemon/daemon.h @@ -1,26 +1,25 @@  #ifndef foodaemonhfoo  #define foodaemonhfoo -/* $Id: exec.h 4 2003-08-10 19:56:53Z lennart $ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  /** \file   * diff --git a/libdaemon/dexec.c b/libdaemon/dexec.c index 0a21777..f0d8415 100644 --- a/libdaemon/dexec.c +++ b/libdaemon/dexec.c @@ -1,23 +1,22 @@ -/* $Id: exec.c 31 2003-11-05 22:04:26Z lennart $ */ - -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> @@ -59,21 +58,21 @@ int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap) {          daemon_log(LOG_ERR, "pipe() failed: %s", strerror(errno));          return -1;      } -     +      if ((pid = fork()) < 0) {          daemon_log(LOG_ERR, "fork() failed: %s", strerror(errno));          return -1; -         +      } else if (pid == 0) {          char *args[MAX_ARGS];          int i; -         +          if (p[1] != 1)              dup2(p[1], 1);          if (p[1] != 2)              dup2(p[1], 2); -         +          if (p[0] > 2)              close(p[0]); @@ -87,28 +86,28 @@ int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap) {          }          daemon_close_all(-1); -         +  	umask(0022); /* Set up a sane umask */ -         +          if (dir && chdir(dir) < 0) {              daemon_log(LOG_WARNING, "Failed to change to directory '%s'", dir);              chdir("/");          } -         +          for (i = 0; i < MAX_ARGS-1; i++)              if (!(args[i] = va_arg(ap, char*)))                  break;          args[i] = NULL; -         +          execv(prog, args); -         +          daemon_log(LOG_ERR, "execv(%s) failed: %s", prog, strerror(errno)); -         +          _exit(EXIT_FAILURE);      } -     +      close(p[1]); -     +      FD_ZERO(&fds);      FD_SET(p[0], &fds);      sigfd = daemon_signal_fd(); @@ -135,41 +134,41 @@ int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap) {                  break;              buf[n] = c; -             +              if (c == '\n' || n >= sizeof(buf) - 2) {                  if (c != '\n') n++;                  buf[n] = 0; -                if (buf[0])  -                    daemon_log(LOG_INFO, "client: %s", buf);  -                 +                if (buf[0]) +                    daemon_log(LOG_INFO, "client: %s", buf); +                  n = 0;              } else                  n++;          } -         +          if (FD_ISSET(sigfd, &qfds)) {              int sig; -             +              if ((sig = daemon_signal_next()) < 0) {                  daemon_log(LOG_ERR, "daemon_signal_next(): %s", strerror(errno));                  break;              } -             +              if (sig != SIGCHLD) {                  daemon_log(LOG_WARNING, "Killing child.");                  kill(pid, SIGTERM);              }          }      } -     +      if (n > 0) {          buf[n] = 0; -        daemon_log(LOG_WARNING, "client: %s", buf);  +        daemon_log(LOG_WARNING, "client: %s", buf);      }      close(p[0]); -     +      for (;;) {          if (waitpid(pid, &r, 0) < 0) { @@ -193,7 +192,7 @@ int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap) {  int daemon_exec(const char *dir, int *ret, const char *prog, ...) {      va_list ap;      int r; -     +      va_start(ap, prog);      r = daemon_execv(dir, ret, prog, ap);      va_end(ap); diff --git a/libdaemon/dexec.h b/libdaemon/dexec.h index ebfbee5..1f7f7e8 100644 --- a/libdaemon/dexec.h +++ b/libdaemon/dexec.h @@ -1,26 +1,25 @@  #ifndef foodexechfoo  #define foodexechfoo -/* $Id: exec.h 4 2003-08-10 19:56:53Z lennart $ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #include <stdarg.h> @@ -43,14 +42,14 @@ extern "C" {  #else  #define DAEMON_GCC_SENTINEL  #endif -     +  /** Run the specified executable with the specified arguments in the   * specified directory and return the return value of the program in   * the specified pointer. The calling process is blocked until the   * child finishes and all child output (either STDOUT or STDIN) has   * been written to syslog. Running this function requires that   * daemon_signal() has been called with SIGCHLD as argument. - *  + *   * @param dir Working directory for the process.   * @param ret A pointer to an integer to write the return value of the program to.   * @param prog The path to the executable @@ -64,7 +63,7 @@ int daemon_exec(const char *dir, int *ret, const char *prog, ...) DAEMON_GCC_SEN  /** The same as daemon_exec, but without variadic arguments */  int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap); -     +  #ifdef __cplusplus  }  #endif diff --git a/libdaemon/dfork.c b/libdaemon/dfork.c index 514a356..464af49 100644 --- a/libdaemon/dfork.c +++ b/libdaemon/dfork.c @@ -1,23 +1,22 @@ -/* $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 Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> diff --git a/libdaemon/dfork.h b/libdaemon/dfork.h index 7d9b62a..566844f 100644 --- a/libdaemon/dfork.h +++ b/libdaemon/dfork.h @@ -1,26 +1,25 @@  #ifndef foodaemonforkhfoo  #define foodaemonforkhfoo -/* $Id$ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #include <sys/types.h> diff --git a/libdaemon/dlog.c b/libdaemon/dlog.c index f832147..a5c8e44 100644 --- a/libdaemon/dlog.c +++ b/libdaemon/dlog.c @@ -1,23 +1,22 @@ -/* $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 Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> @@ -35,9 +34,9 @@ const char* daemon_log_ident = NULL;  void daemon_logv(int prio, const char* template, va_list arglist) {      int saved_errno; -     +      saved_errno = errno; -     +      if (daemon_log_use & DAEMON_LOG_SYSLOG) {  	openlog(daemon_log_ident ? daemon_log_ident : "UNKNOWN", LOG_PID, LOG_DAEMON);          vsyslog(prio | LOG_DAEMON, template, arglist); @@ -58,7 +57,7 @@ void daemon_logv(int prio, const char* template, va_list arglist) {  void daemon_log(int prio, const char* template, ...) {      va_list arglist; -     +      va_start(arglist, template);      daemon_logv(prio, template, arglist);      va_end(arglist); diff --git a/libdaemon/dlog.h b/libdaemon/dlog.h index 09479be..814171f 100644 --- a/libdaemon/dlog.h +++ b/libdaemon/dlog.h @@ -1,26 +1,25 @@  #ifndef foodaemonloghfoo  #define foodaemonloghfoo -/* $Id$ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #include <syslog.h>  #include <stdarg.h> diff --git a/libdaemon/dnonblock.c b/libdaemon/dnonblock.c index 79b743a..b93d875 100644 --- a/libdaemon/dnonblock.c +++ b/libdaemon/dnonblock.c @@ -1,23 +1,22 @@ -/* $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 Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> diff --git a/libdaemon/dnonblock.h b/libdaemon/dnonblock.h index 39dd30b..8c5b8fd 100644 --- a/libdaemon/dnonblock.h +++ b/libdaemon/dnonblock.h @@ -1,26 +1,25 @@  #ifndef foodaemonnonblockhfoo  #define foodaemonnonblockhfoo -/* $Id$ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef __cplusplus  extern "C" { diff --git a/libdaemon/dpid.c b/libdaemon/dpid.c index 10b9b77..145cf50 100644 --- a/libdaemon/dpid.c +++ b/libdaemon/dpid.c @@ -1,23 +1,22 @@ -/* $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 Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> diff --git a/libdaemon/dpid.h b/libdaemon/dpid.h index 963fe4c..01d87f3 100644 --- a/libdaemon/dpid.h +++ b/libdaemon/dpid.h @@ -1,26 +1,25 @@  #ifndef foodaemonpidhfoo  #define foodaemonpidhfoo -/* $Id$ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #include <sys/types.h> diff --git a/libdaemon/dsignal.c b/libdaemon/dsignal.c index 781aa00..a759464 100644 --- a/libdaemon/dsignal.c +++ b/libdaemon/dsignal.c @@ -1,23 +1,22 @@ -/* $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 Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +/*** +  This file is part of libdaemon. + +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef HAVE_CONFIG_H  #include <config.h> @@ -63,7 +62,7 @@ int daemon_signal_install(int s){      if (_init() < 0)          return -1; -     +      if (sigemptyset(&ss) < 0) {          daemon_log(LOG_ERR, "sigemptyset(): %s", strerror(errno));          return -1; @@ -83,7 +82,7 @@ int daemon_signal_install(int s){      sa.sa_handler = _sigfunc;      sigemptyset(&sa.sa_mask);      sa.sa_flags = SA_RESTART; -         +      if (sigaction(s, &sa, NULL) < 0) {          daemon_log(LOG_ERR, "sigaction(%s, ...) failed: %s", strsignal(s), strerror(errno));          return -1; @@ -94,7 +93,7 @@ int daemon_signal_install(int s){  int daemon_signal_init(int s, ...) {      int sig, r = 0; -     +      va_list ap;      va_start(ap, s); @@ -107,19 +106,19 @@ int daemon_signal_init(int s, ...) {              r = -1;              break;          } -         +          sig = va_arg(ap, int);      } -             +      va_end(ap); -  +      return r;  }  void daemon_signal_done(void) {      if (_signal_pipe[0] != -1)          close(_signal_pipe[0]); -     +      if (_signal_pipe[1] != -1)          close(_signal_pipe[1]); @@ -132,7 +131,7 @@ int daemon_signal_next(void) {      if ((r = read(_signal_pipe[0], &s, sizeof(s))) == sizeof(s))          return s; -     +      if (r < 0) {          if (errno == EAGAIN) @@ -142,7 +141,7 @@ int daemon_signal_next(void) {              return -1;          }      } -     +      daemon_log(LOG_ERR, "Short read() on signal pipe.");      return -1;  } diff --git a/libdaemon/dsignal.h b/libdaemon/dsignal.h index b73f19a..1719784 100644 --- a/libdaemon/dsignal.h +++ b/libdaemon/dsignal.h @@ -1,26 +1,25 @@  #ifndef foodaemonsignalhfoo  #define foodaemonsignalhfoo -/* $Id$ */ +/*** +  This file is part of libdaemon. -/* - * This file is part of libdaemon. - * - * libdaemon is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation; either version 2.1 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libdaemon; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - */ +  Copyright 2003-2008 Lennart Poettering + +  libdaemon is free software; you can redistribute it and/or modify +  it under the terms of the GNU Lesser General Public License as +  published by the Free Software Foundation, either version 2.1 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 +  Lesser General Public License for more details. + +  You should have received a copy of the GNU Lesser General Public +  License along with libdaemon. If not, see +  <http://www.gnu.org/licenses/>. +***/  #ifdef __cplusplus  extern "C" {  | 
