Index: lib/profile/InstrProfilingFile.c =================================================================== --- lib/profile/InstrProfilingFile.c +++ lib/profile/InstrProfilingFile.c @@ -28,6 +28,8 @@ #include #if defined(__linux__) #include +#include +#include #endif #endif @@ -524,6 +526,9 @@ int rc, Length; const char *Filename; char *FilenameBuf; +#if defined(__linux__) + int PDeachSig = 0; +#endif if (lprofProfileDumped()) { PROF_NOTE("Profile data not written to file: %s.\n", @@ -550,10 +555,22 @@ return -1; } +#if defined(__linux__) + // Temporarily suspend getting SIGKILL when the parent exits. + if (prctl(PR_GET_PDEATHSIG, &PDeachSig) == 0 && PDeachSig == SIGKILL) + prctl(PR_SET_PDEATHSIG, 0); +#endif + /* Write profile data to the file. */ rc = writeFile(Filename); if (rc) PROF_ERR("Failed to write file \"%s\": %s\n", Filename, strerror(errno)); + +#if defined(__linux__) + // Restore PR_SET_PDEATHSIG. + if (PDeachSig == SIGKILL) + prctl(PR_SET_PDEATHSIG, SIGKILL); +#endif return rc; }