Code

Attempt at detecting 64bit compilation flags between gcc, old, and new versions of...
[nagiosplug.git] / plugins / runcmd.c
index 4155796c5575730d74d746a5e4d9fdf0ad2529ab..7574b1213b7b10a31ce1f5a35409844caee29dd0 100644 (file)
@@ -1,20 +1,40 @@
-/*
- * $Id$
- *
- * A simple interface to executing programs from other programs, using an
- * optimized and safe popen()-like implementation. It is considered safe
- * in that no shell needs to be spawned and the environment passed to the
- * execve()'d program is essentially empty.
- *
- *
- * The code in this file is a derivative of popen.c which in turn was taken
- * from "Advanced Programming for the Unix Environment" by W. Richard Stevens.
- *
- * Care has been taken to make sure the functions are async-safe. The one
- * function which isn't is np_runcmd_init() which it doesn't make sense to
- * call twice anyway, so the api as a whole should be considered async-safe.
- *
- */
+/*****************************************************************************
+* 
+* Nagios run command utilities
+* 
+* License: GPL
+* Copyright (c) 2005-2006 Nagios Plugins Development Team
+* 
+* Description :
+* 
+* A simple interface to executing programs from other programs, using an
+* optimized and safe popen()-like implementation. It is considered safe
+* in that no shell needs to be spawned and the environment passed to the
+* execve()'d program is essentially empty.
+* 
+* The code in this file is a derivative of popen.c which in turn was taken
+* from "Advanced Programming for the Unix Environment" by W. Richard Stevens.
+* 
+* Care has been taken to make sure the functions are async-safe. The one
+* function which isn't is np_runcmd_init() which it doesn't make sense to
+* call twice anyway, so the api as a whole should be considered async-safe.
+* 
+* 
+* This program 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 3 of the License, or
+* (at your option) any later version.
+* 
+* This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+* 
+* 
+*****************************************************************************/
 
 #define NAGIOSPLUG_API_C 1
 
@@ -137,7 +157,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
        argv = calloc(sizeof(char *), argc);
 
        if (argv == NULL) {
-               printf (_("Could not malloc argv array in popen()\n"));
+               printf ("%s\n", _("Could not malloc argv array in popen()"));
                return -1;
        }
 
@@ -198,7 +218,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
                                close (i);
 
                execve (argv[0], argv, env);
-               _exit (0);
+               _exit (STATE_UNKNOWN);
        }
 
        /* parent picks up execution here */