try harder to remove "OSL_PIPE" pipe on SIGTERM

a) When oosplash got SIGTERM it used SIGKILL on soffice.bin, (concealed
behind osl_terminateProcess) so soffice.bin has no chance to cleanup.

Try SIGTERM, followed by SIGKILL if that doesn't work, to give
soffice.bin a chance.

b) java intercepts SIGTERM so if JNI_CreateJavaVM was called then
our SIGTERM handler doesn't get called. Add -Xrs to jvm args to
avoid this.

Change-Id: I09f93d8093bc7c094482eda73b4eadc5a6cebb83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140152
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2022-09-19 18:28:33 +02:00
parent bbc07c964e
commit 6352710e02
2 changed files with 23 additions and 3 deletions
+17 -2
View File
@@ -722,8 +722,23 @@ static void sigterm_handler(int ignored)
(void) ignored;
if (g_pProcess) {
osl_terminateProcess(g_pProcess); // forward signal to soffice.bin
osl_joinProcess(g_pProcess);
int SigTermSucceded = 0;
oslProcessInfo info;
info.Size = sizeof(oslProcessInfo);
// forward SIGTERM to soffice.bin and give it a chance to semi-gracefully exit
// enough to remove named pipe
if (osl_getProcessInfo(g_pProcess, osl_Process_IDENTIFIER, &info) == osl_Process_E_None) {
TimeValue delay = { 1, 0 }; // 1 sec
SigTermSucceded = kill(info.Ident, SIGTERM) == 0 &&
osl_joinProcessWithTimeout(g_pProcess, &delay) == osl_Process_E_None;
}
// didn't work, SIGKILL instead
if (!SigTermSucceded) {
osl_terminateProcess(g_pProcess); // uses SIGKILL to terminate soffice.bin
osl_joinProcess(g_pProcess);
}
}
_exit(255);
+6 -1
View File
@@ -229,7 +229,7 @@ javaFrameworkError jfw_startVM(
//options dialog
std::unique_ptr<JavaVMOption[]> sarJOptions(
new JavaVMOption[
arOptions.size() + (sUserClassPath.isEmpty() ? 1 : 2) + vmParams.size()]);
arOptions.size() + (sUserClassPath.isEmpty() ? 2 : 3) + vmParams.size()]);
JavaVMOption * arOpt = sarJOptions.get();
if (! arOpt)
return JFW_E_ERROR;
@@ -248,6 +248,11 @@ javaFrameworkError jfw_startVM(
arOpt[index].extraInfo = nullptr;
++index;
// Don't intercept SIGTERM
arOpt[index].optionString = const_cast<char *>("-Xrs");
arOpt[index].extraInfo = nullptr;
++index;
//add the options set by options dialog
for (auto const & vmParam : vmParams)
{