File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,25 @@ static void check_child_processes(GHashTable *pid_to_handler, GHashTable *cache)
4646 continue ;
4747
4848 if (pid < 0 && errno == ECHILD ) {
49+ /* Before quitting, check if container_pid is still alive.
50+ * In some systemd configurations, the container process may not be
51+ * a direct child, so we won't receive SIGCHLD when it exits.
52+ * Use kill(pid, 0) to check if the process still exists. */
53+ if (container_pid > 0 ) {
54+ if (kill (container_pid , 0 ) == 0 ) {
55+ /* Container process is still alive but not our child.
56+ * Don't quit the main loop yet. */
57+ ninfof ("Container process %d is still alive but not a direct child" , container_pid );
58+ return ;
59+ } else if (errno == ESRCH ) {
60+ /* Container process has exited */
61+ ninfof ("Container process %d has exited (detected via kill probe)" , container_pid );
62+ /* Simulate container exit callback */
63+ container_status = 0 ; /* We can't get the real exit status */
64+ container_pid = -1 ;
65+ /* Fall through to quit the main loop */
66+ }
67+ }
4968 g_main_loop_quit (main_loop );
5069 return ;
5170 }
You can’t perform that action at this time.
0 commit comments