diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-06-05 05:33:46 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2012-06-05 05:33:46 +0200 |
commit | 13dea84f03192994a1809f76db41c506ec82e916 (patch) | |
tree | d94f6a80de08e3304cd1913c087cb7c4bebc240c /honeypot.c | |
parent | More careful fork semantics to stop zombies. (diff) | |
download | telnet-password-honeypot-13dea84f03192994a1809f76db41c506ec82e916.tar.xz telnet-password-honeypot-13dea84f03192994a1809f76db41c506ec82e916.zip |
Fix silly error in waiting.
Diffstat (limited to 'honeypot.c')
-rw-r--r-- | honeypot.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -128,8 +128,8 @@ void SIGCHLD_handler(int sig) { int status; pid_t pid; - - while ((pid = wait(-1, &status, WNOHANG)) > 0) + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) printf("Process %d has exited with code %d.\n", pid, WEXITSTATUS(status)); } @@ -647,14 +647,16 @@ int main(int argc, char *argv[]) (connection_fd = accept(listen_fd, (struct sockaddr *)&connection_addr, &connection_addr_len)) >= 0) { child = fork(); if (child < 0) { - close(connection_fd); perror("fork"); + close(connection_fd); continue; } if (!child) { char ipaddr[INET6_ADDRSTRLEN]; struct in6_addr *v6; - + prctl(PR_SET_PDEATHSIG, SIGHUP); + if (getppid() == 1) + kill(getpid(), SIGHUP); prctl(PR_SET_NAME, "honeypot serve"); close(listen_fd); memset(ipaddr, 0, sizeof(ipaddr)); |