New upstream version 2.3.4
This commit is contained in:
parent
e7bdd1c6c6
commit
de72f6f588
556 changed files with 90432 additions and 53391 deletions
|
@ -44,6 +44,8 @@
|
|||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#include "./utils.h"
|
||||
|
||||
/** macros **/
|
||||
#ifndef WEXITSTATUS
|
||||
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
|
||||
|
@ -58,6 +60,8 @@
|
|||
# define SIG_ERR ((Sigfunc *)-1)
|
||||
#endif
|
||||
|
||||
#include "../lib/maxfd.h"
|
||||
|
||||
/* This variable must be global, since there's no way the caller
|
||||
* can forcibly slay a dead or ungainly running program otherwise.
|
||||
* Multithreading apps and plugins can initialize it (via NP_RUNCMD_INIT)
|
||||
|
@ -86,8 +90,7 @@ extern void die (int, const char *, ...)
|
|||
* through this api and thus achieve async-safeness throughout the api */
|
||||
void np_runcmd_init(void)
|
||||
{
|
||||
if(maxfd == 0)
|
||||
maxfd = open_max();
|
||||
long maxfd = mp_open_max();
|
||||
if(!np_pids) np_pids = calloc(maxfd, sizeof(pid_t));
|
||||
}
|
||||
|
||||
|
@ -114,10 +117,6 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
|
|||
env[0] = strdup("LC_ALL=C");
|
||||
env[1] = '\0';
|
||||
|
||||
/* if no command was passed, return with no error */
|
||||
if (cmdstring == NULL)
|
||||
return -1;
|
||||
|
||||
/* make copy of command string so strtok() doesn't silently modify it */
|
||||
/* (the calling program may want to access it later) */
|
||||
cmdlen = strlen(cmdstring);
|
||||
|
@ -194,6 +193,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
|
|||
/* close all descriptors in np_pids[]
|
||||
* This is executed in a separate address space (pure child),
|
||||
* so we don't have to worry about async safety */
|
||||
long maxfd = mp_open_max();
|
||||
for (i = 0; i < maxfd; i++)
|
||||
if(np_pids[i] > 0)
|
||||
close (i);
|
||||
|
@ -203,7 +203,7 @@ np_runcmd_open(const char *cmdstring, int *pfd, int *pfderr)
|
|||
}
|
||||
|
||||
/* parent picks up execution here */
|
||||
/* close childs descriptors in our address space */
|
||||
/* close children descriptors in our address space */
|
||||
close(pfd[1]);
|
||||
close(pfderr[1]);
|
||||
|
||||
|
@ -221,6 +221,7 @@ np_runcmd_close(int fd)
|
|||
pid_t pid;
|
||||
|
||||
/* make sure this fd was opened by popen() */
|
||||
long maxfd = mp_open_max();
|
||||
if(fd < 0 || fd > maxfd || !np_pids || (pid = np_pids[fd]) == 0)
|
||||
return -1;
|
||||
|
||||
|
@ -244,6 +245,7 @@ runcmd_timeout_alarm_handler (int signo)
|
|||
if (signo == SIGALRM)
|
||||
puts(_("CRITICAL - Plugin timed out while executing system call"));
|
||||
|
||||
long maxfd = mp_open_max();
|
||||
if(np_pids) for(i = 0; i < maxfd; i++) {
|
||||
if(np_pids[i] != 0) kill(np_pids[i], SIGKILL);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue