NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/57579: ctwm application menu hangs because of SIGCHLD/SIG_IGN/system(3) interaction



The following reply was made to PR xsrc/57579; it has been noted by GNATS.

From: Rhialto <rhialto%falu.nl@localhost>
To: gnats-admin%NetBSD.org@localhost
Cc: 
Subject: Re: pkg/57579: ctwm application menu hangs because of
 SIGCHLD/SIG_IGN/system(3) interaction
Date: Sat, 12 Aug 2023 16:18:38 +0200

 This should fix it; but I didn't test this instance of the patch.
 It is a copy of the change I proposed to the current upstream ctwm code,
 which I did test (before and after). I changed my .xsession setup for it
 since in my normal version I end it with starting an xterm instead of
 the window manager, and in that case the problem doesn't show.
 
 Index: signals.c
 ===================================================================
 RCS file: /cvsroot/xsrc/external/mit/ctwm/dist/signals.c,v
 retrieving revision 1.1.1.1
 diff -u -r1.1.1.1 signals.c
 --- signals.c	5 Jul 2023 07:36:07 -0000	1.1.1.1
 +++ signals.c	12 Aug 2023 14:12:23 -0000
 @@ -8,6 +8,7 @@
  #include <stdio.h>
  #include <stdlib.h>
  #include <unistd.h>
 +#include <sys/wait.h>
  
  #include "ctwm_shutdown.h"
  #include "signals.h"
 @@ -16,6 +17,7 @@
  /* Our backends */
  static void sh_restart(int signum);
  static void sh_shutdown(int signum);
 +static void sh_sigchld(int signum);
  
  
  // Internal flags for which signals have called us
 @@ -46,9 +48,8 @@
  	// die...
  	signal(SIGALRM, SIG_IGN);
  
 -	// This should be set by default, but just in case; explicitly don't
 -	// leave zombies.
 -	signal(SIGCHLD, SIG_IGN);
 +	// Explicitly don't leave zombies.
 +	signal(SIGCHLD, sh_sigchld);
  
  	return;
  }
 @@ -123,3 +124,15 @@
  	SignalFlag = sig_shutdown = true;
  }
  
 +/**
 + * Handle SIGCHLD so we don't leave zombie child processes.
 + */
 +static void
 +sh_sigchld(int signum)
 +{
 +	pid_t pid;
 +	int status;
 +
 +	while((pid = waitpid(-1, &status, WNOHANG)) > 0)
 +		;
 +}
 


Home | Main Index | Thread Index | Old Index