summaryrefslogtreecommitdiffstats
path: root/honeypot.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2012-06-05 05:33:46 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2012-06-05 05:33:46 +0200
commit13dea84f03192994a1809f76db41c506ec82e916 (patch)
treed94f6a80de08e3304cd1913c087cb7c4bebc240c /honeypot.c
parentMore careful fork semantics to stop zombies. (diff)
downloadtelnet-password-honeypot-13dea84f03192994a1809f76db41c506ec82e916.tar.xz
telnet-password-honeypot-13dea84f03192994a1809f76db41c506ec82e916.zip
Fix silly error in waiting.
Diffstat (limited to 'honeypot.c')
-rw-r--r--honeypot.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/honeypot.c b/honeypot.c
index 9d120b0..987f421 100644
--- a/honeypot.c
+++ b/honeypot.c
@@ -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));