8357683: (process) SIGQUIT still blocked after JDK-8234262 with jdk.lang.Process.launchMechanism=FORK or VFORK

Reviewed-by: rriggs
This commit is contained in:
Thomas Stuefe 2025-05-30 13:40:25 +00:00
parent 12ee80cac7
commit ae3d96a4ec
3 changed files with 24 additions and 10 deletions

View File

@ -26,7 +26,6 @@
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -145,7 +144,6 @@ int main(int argc, char *argv[]) {
struct stat buf;
/* argv[1] contains the fd number to read all the child info */
int r, fdinr, fdinw, fdout;
sigset_t unblock_signals;
#ifdef DEBUG
jtregSimulateCrash(0, 4);
@ -173,10 +171,6 @@ int main(int argc, char *argv[]) {
shutItDown();
}
// Reset any mask signals from parent
sigemptyset(&unblock_signals);
sigprocmask(SIG_SETMASK, &unblock_signals, NULL);
// Close the writing end of the pipe we use for reading from the parent.
// We have to do this before we start reading from the parent to avoid
// blocking in the case the parent exits before we finished reading from it.

View File

@ -26,6 +26,7 @@
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -405,6 +406,13 @@ childProcess(void *arg)
if (p->pdir != NULL && chdir(p->pdir) < 0)
goto WhyCantJohnnyExec;
// Reset any mask signals from parent, but not in VFORK mode
if (p->mode != MODE_VFORK) {
sigset_t unblock_signals;
sigemptyset(&unblock_signals);
sigprocmask(SIG_SETMASK, &unblock_signals, NULL);
}
if (fcntl(FAIL_FILENO, F_SETFD, FD_CLOEXEC) == -1)
goto WhyCantJohnnyExec;

View File

@ -24,15 +24,27 @@
import java.io.IOException;
/*
* @test
* @summary Verify Signal mask is cleared by ProcessBuilder start
* @test id=posix_spawn
* @summary Verify Signal mask is cleared by ProcessBuilder start when using posix_spawn mode
* @bug 8234262
* @requires (os.family == "linux" | os.family == "mac")
* @comment Don't allow -Xcomp, it disturbs the relative timing of the sleep and kill commands
* @requires (vm.compMode != "Xcomp")
* @run main/othervm UnblockSignals
* @run main/othervm -Xrs UnblockSignals
* @run main/othervm -Djdk.lang.Process.launchMechanism=POSIX_SPAWN UnblockSignals
* @run main/othervm -Djdk.lang.Process.launchMechanism=POSIX_SPAWN -Xrs UnblockSignals
*/
/*
* @test id=fork
* @summary Verify Signal mask is cleared by ProcessBuilder start when using fork mode
* @bug 8357683
* @requires (os.family == "linux" | os.family == "mac")
* @comment Don't allow -Xcomp, it disturbs the relative timing of the sleep and kill commands
* @requires (vm.compMode != "Xcomp")
* @run main/othervm -Djdk.lang.Process.launchMechanism=FORK UnblockSignals
* @run main/othervm -Djdk.lang.Process.launchMechanism=FORK -Xrs UnblockSignals
*/
public class UnblockSignals {
public static void main(String[] args) throws IOException, InterruptedException {
// Check that SIGQUIT is not masked, in previous releases it was masked