about summary refs log tree commit diff
path: root/sysdeps/posix/profil.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/posix/profil.c')
-rw-r--r--sysdeps/posix/profil.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sysdeps/posix/profil.c b/sysdeps/posix/profil.c
index a6786b1a13..ddbd80a505 100644
--- a/sysdeps/posix/profil.c
+++ b/sysdeps/posix/profil.c
@@ -78,6 +78,15 @@ profil (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
       return sigaction (SIGPROF, &oact, NULL);
     }
 
+ if (samples)
+    {
+      /* Was already turned on.  Restore old timer and signal handler
+	 first.  */
+      if (setitimer (ITIMER_PROF, &otimer, NULL) < 0
+	  || sigaction (SIGPROF, &oact, NULL) < 0)
+	return -1;
+    }
+
   samples = sample_buffer;
   nsamples = size / sizeof *samples;
   pc_offset = offset;