mirror of
https://github.com/nmap/nmap.git
synced 2026-10-24 21:02:11 +00:00
Wait for remaining children from -lk with cmdexec
Some checks failed
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Has been cancelled
Some checks failed
nmap multiplatform autobuilds / build (arm64, gcc, ubuntu-latest-gcc-arm64, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, freebsd-15-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-15-clang, macos-15) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, macos-26-clang, macos-26) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, netbsd-10-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, openbsd-7-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, solaris-11-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (clang, ubuntu-latest-clang, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (egcc, openbsd-7-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, freebsd-15-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, netbsd-10-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, solaris-11-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (gcc, ubuntu-latest-gcc, ubuntu-latest) (push) Has been cancelled
nmap multiplatform autobuilds / build (msvc, windows-latest-msvc, windows-latest) (push) Has been cancelled
This commit is contained in:
parent
eb31283031
commit
10dfd2ff1c
2 changed files with 39 additions and 1 deletions
|
|
@ -489,6 +489,20 @@ restart_fd_loop:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
/* Reap remaining children */
|
||||||
|
Signal(SIGCHLD, SIG_DFL);
|
||||||
|
while (waitpid(-1, NULL, 0) < 0) {
|
||||||
|
if (errno == ECHILD) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
die("waitpid");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return (breakloop == BREAKLOOP_ERROR ? 1 : 0);
|
return (breakloop == BREAKLOOP_ERROR ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,16 @@
|
||||||
|
|
||||||
char **cmdline_split(const char *cmdexec);
|
char **cmdline_split(const char *cmdexec);
|
||||||
|
|
||||||
|
static int child_alive = 0;
|
||||||
|
|
||||||
|
static void sigchld_watcher(int signum)
|
||||||
|
{
|
||||||
|
int saved_errno = errno;
|
||||||
|
if (waitpid(-1, NULL, WNOHANG) > 0)
|
||||||
|
child_alive = 0;
|
||||||
|
errno = saved_errno;
|
||||||
|
}
|
||||||
|
|
||||||
/* fork and exec a child process with netexec. Close the given file descriptor
|
/* fork and exec a child process with netexec. Close the given file descriptor
|
||||||
in the parent process. Return the child's PID or -1 on error. */
|
in the parent process. Return the child's PID or -1 on error. */
|
||||||
int netrun(struct fdinfo *info, char *cmdexec)
|
int netrun(struct fdinfo *info, char *cmdexec)
|
||||||
|
|
@ -177,6 +187,10 @@ void netexec(struct fdinfo *info, char *cmdexec)
|
||||||
if (pipe(child_stdin) == -1 || pipe(child_stdout) == -1)
|
if (pipe(child_stdin) == -1 || pipe(child_stdout) == -1)
|
||||||
bye("Can't create child pipes: %s", strerror(errno));
|
bye("Can't create child pipes: %s", strerror(errno));
|
||||||
|
|
||||||
|
/* No longer using ncat_listen.c's sigchld_handler */
|
||||||
|
Signal(SIGCHLD, sigchld_watcher);
|
||||||
|
|
||||||
|
child_alive = 1;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (pid == -1)
|
if (pid == -1)
|
||||||
bye("Error in fork: %s", strerror(errno));
|
bye("Error in fork: %s", strerror(errno));
|
||||||
|
|
@ -242,7 +256,7 @@ void netexec(struct fdinfo *info, char *cmdexec)
|
||||||
checked_fd_set(child_stdout[0], &all_fds);
|
checked_fd_set(child_stdout[0], &all_fds);
|
||||||
#define PIPE_CLOSE(_PipeName) shutdown_##_PipeName(info, child_stdout[0], child_stdin[1], &all_fds, &maxfd)
|
#define PIPE_CLOSE(_PipeName) shutdown_##_PipeName(info, child_stdout[0], child_stdin[1], &all_fds, &maxfd)
|
||||||
|
|
||||||
while (maxfd >= 0) {
|
while (child_alive && maxfd >= 0) {
|
||||||
fd_set fds = all_fds;
|
fd_set fds = all_fds;
|
||||||
int r, n_r;
|
int r, n_r;
|
||||||
|
|
||||||
|
|
@ -312,6 +326,16 @@ void netexec(struct fdinfo *info, char *cmdexec)
|
||||||
#endif
|
#endif
|
||||||
close(info->fd);
|
close(info->fd);
|
||||||
|
|
||||||
|
while (waitpid(pid, NULL, 0) < 0) {
|
||||||
|
if (errno == ECHILD) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (errno == EINTR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
die("waitpid");
|
||||||
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue