libjsig没有帮助,因为SIGCHLD处理程序是由 JVM 本身安装的libjava,而不是由 JVM 本身安装的。
sigaction(SIGCHLD, ...)带有 sa_handler =SIG_DFL的 Java 类库仅在 java.lang.UNIXProcess 的静态初始化程序中调用一次。
现在,您可以使用以下选项来解决此问题。
最简单的一个。只需在java.lang.UNIXProcess. _
创建您自己的钩子,当使用和参数调用时LD_PRELOAD将拦截sigaction并忽略它:SIGCHLDSIG_DFL
例如
#define _GNU_SOURCE
#include <signal.h>
#include <dlfcn.h>
#include <stddef.h>
int sigaction(int signum, const struct sigaction* act, struct sigaction* oldact) {
static int (*real_sa)(int, const struct sigaction*, struct sigaction*) = NULL;
if (signum == SIGCHLD && act->sa_handler == SIG_DFL) {
return 0;
}
if (real_sa == NULL) {
real_sa = dlsym(RTLD_NEXT, "sigaction");
}
return real_sa(signum, act, oldact);
}