summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfilingFile.c
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2017-03-17 18:41:33 +0000
committerRong Xu <xur@google.com>2017-03-17 18:41:33 +0000
commit4fdab5b726a155dd3da614734caa6ba69f2ee80c (patch)
tree9d9de6fd89d5ec9c612a2f495967880c351bbcc9 /lib/profile/InstrProfilingFile.c
parent7e119a30d6b3f35ee22db8a8d7d6839c4c481a29 (diff)
Resubmit r295469 [PGO] Suspend SIGKILL for PR_SET_PDEATHSIG in profile-write
And also r295364 [PGO] remove unintended debug trace. NFC I removed the test case: it's hard to write synchronized test b/w processes in this framework. I will revisit the test-case later. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfilingFile.c')
-rw-r--r--lib/profile/InstrProfilingFile.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/profile/InstrProfilingFile.c b/lib/profile/InstrProfilingFile.c
index cd3590e12..dfcbe52d7 100644
--- a/lib/profile/InstrProfilingFile.c
+++ b/lib/profile/InstrProfilingFile.c
@@ -530,6 +530,7 @@ int __llvm_profile_write_file(void) {
int rc, Length;
const char *Filename;
char *FilenameBuf;
+ int PDeathSig = 0;
if (lprofProfileDumped()) {
PROF_NOTE("Profile data not written to file: %s.\n",
@@ -556,10 +557,18 @@ int __llvm_profile_write_file(void) {
return -1;
}
+ // Temporarily suspend getting SIGKILL when the parent exits.
+ PDeathSig = lprofSuspendSigKill();
+
/* Write profile data to the file. */
rc = writeFile(Filename);
if (rc)
PROF_ERR("Failed to write file \"%s\": %s\n", Filename, strerror(errno));
+
+ // Restore SIGKILL.
+ if (PDeathSig == 1)
+ lprofRestoreSigKill();
+
return rc;
}