1#ifndef foodexechfoo 2#define foodexechfoo 3 4/*** 5 This file is part of libdaemon. 6 7 Copyright 2003-2008 Lennart Poettering 8 9 libdaemon is free software; you can redistribute it and/or modify 10 it under the terms of the GNU Lesser General Public License as 11 published by the Free Software Foundation, either version 2.1 of the 12 License, or (at your option) any later version. 13 14 libdaemon is distributed in the hope that it will be useful, but 15 WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 Lesser General Public License for more details. 18 19 You should have received a copy of the GNU Lesser General Public 20 License along with libdaemon. If not, see 21 <http://www.gnu.org/licenses/>. 22***/ 23 24#include <stdarg.h> 25 26#ifdef __cplusplus 27extern "C" { 28#endif 29 30/** \file 31 * 32 * Contains a robust API for running sub processes with STDOUT and 33 * STDERR redirected to syslog 34 */ 35 36/** This variable is defined to 1 iff daemon_exec() is supported. 37 * @since 0.4 38 * @see daemon_exec() */ 39#define DAEMON_EXEC_AVAILABLE 1 40 41#if defined(__GNUC__) && ! defined(DAEMON_GCC_SENTINEL) 42#define DAEMON_GCC_SENTINEL __attribute__ ((sentinel)) 43#else 44/** A macro for making use of GCCs printf compilation warnings */ 45#define DAEMON_GCC_SENTINEL 46#endif 47 48/** Run the specified executable with the specified arguments in the 49 * specified directory and return the return value of the program in 50 * the specified pointer. The calling process is blocked until the 51 * child finishes and all child output (either STDOUT or STDIN) has 52 * been written to syslog. Running this function requires that 53 * daemon_signal() has been called with SIGCHLD as argument. 54 * 55 * @param dir Working directory for the process. 56 * @param ret A pointer to an integer to write the return value of the program to. 57 * @param prog The path to the executable 58 * @param ... The arguments to be passed to the program, followed by a (char *) NULL 59 * @return Nonzero on failure, zero on success 60 * @since 0.4 61 * @see DAEMON_EXEC_AVAILABLE 62 */ 63int daemon_exec(const char *dir, int *ret, const char *prog, ...) DAEMON_GCC_SENTINEL; 64 65/** This variable is defined to 1 iff daemon_execv() is supported. 66 * @since 0.11 67 * @see daemon_execv() */ 68#define DAEMON_EXECV_AVAILABLE 1 69 70/** The same as daemon_exec, but without variadic arguments 71 * @since 0.11 72 * @see DAEMON_EXECV_AVAILABLE */ 73int daemon_execv(const char *dir, int *ret, const char *prog, va_list ap); 74 75#ifdef __cplusplus 76} 77#endif 78 79#endif 80