From 35d400a8990cfd08caaecc96a87d3686e2a7a166 Mon Sep 17 00:00:00 2001 From: zbstao Date: Thu, 10 Feb 2022 09:42:33 +0800 Subject: [PATCH] Fixed possible SIGCHILD signal lost When multiple(eg. 20) xrdp connections are disconnected at the same time(eg. close all rdp client at the same time), zombie process may be spawned. --- sesman/sig.c | 12 ++++++++---- xrdp/xrdp.c | 4 +--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sesman/sig.c b/sesman/sig.c index 53fb8bd1..fabff3af 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -122,12 +122,16 @@ sig_sesman_session_end(int sig) return; } - pid = g_waitchild(); - - if (pid > 0) + do { - session_kill(pid); + pid = g_waitchild(); + + if (pid > 0) + { + session_kill(pid); + } } + while (pid >= 0); } /******************************************************************************/ diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index ecaa9983..6da93884 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -163,9 +163,7 @@ xrdp_shutdown(int sig) static void xrdp_child(int sig) { - int safety; - - for (safety = 0; (g_waitchild() >= 0) && (safety <= 10); safety++) + while (g_waitchild() >= 0) { } }