tech-toolchain archive

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

Re: make: compat should let child die first on Interrupt.



Christos Zoulas <christos%zoulas.com@localhost> wrote:

> On Jul 19,  8:06pm, sjg%juniper.net@localhost (Simon J Gerraty) wrote:
> -- Subject: make: compat should let child die first on Interrupt.
> 
> Sure, perhaps safer to:
> 
> Index: compat.c
> ===================================================================
> RCS file: /cvsroot/src/usr.bin/make/compat.c,v
> retrieving revision 1.106
> diff -u -u -r1.106 compat.c
> --- compat.c	26 Aug 2016 23:28:39 -0000	1.106
> +++ compat.c	20 Jul 2017 12:33:21 -0000
> @@ -115,6 +115,8 @@
>  static GNode	    *curTarg = NULL;
>  static GNode	    *ENDNode;
>  static void CompatInterrupt(int);
> +static pid_t compatChild;
> +static int compatSigno;
>  
>  /*
>   * CompatDeleteTarget -- delete a failed, interrupted, or otherwise
> @@ -173,8 +175,15 @@
>      }
>      if (signo == SIGQUIT)
>  	_exit(signo);
> -    bmake_signal(signo, SIG_DFL);
> -    kill(myPid, signo);
> +    compatSigno = signo;
> +    if (compatChild > 0) {

Actually in my current patch I have:

-    bmake_signal(signo, SIG_DFL);
-    kill(myPid, signo);
+    signaled = signo;
+    /*
+     * If there is a child running, pass the signal on
+     * we will exist after it has exited.
+     */
+    if (compatChild == 0 ||
+	KILLPG(compatChild, signo) < 0) {
+	bmake_signal(signo, SIG_DFL);
+	kill(myPid, signo);
+    }

since child may have exited already in which case we can die now.
Hmm, though if we die here before reaping the child, we'll skip
reporting why it exited.

I clear compatChild after it exits - there could be more signals to pass
on ;-)

Will rename signald as suggested.


> @@ -481,6 +490,13 @@
>      }
>      free(cmdStart);
>  
> +    if (compatSigno) {
> +	int signo = compatSigno;
> +	compatSigno = 0;

That seems overkill considering we are about to die.

> +	bmake_signal(signo, SIG_DFL);
> +	kill(myPid, signo);
> +    }
> +    
>      return (status);
>  }

Thanks
--sjg


Home | Main Index | Thread Index | Old Index