summaryrefslogtreecommitdiffstats
path: root/lib/libc/gmon/gmon.c
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2012-04-29 22:19:58 +0000
committereadler <eadler@FreeBSD.org>2012-04-29 22:19:58 +0000
commitb7552d49546889fdff72fe0708b52cbb5a08f20c (patch)
treed21f5c9f8c3c81465e6a87d39ec684b17063d821 /lib/libc/gmon/gmon.c
parent1781eecdcd7b19cac0f17520144ae08d3a9a01ab (diff)
downloadFreeBSD-src-b7552d49546889fdff72fe0708b52cbb5a08f20c.zip
FreeBSD-src-b7552d49546889fdff72fe0708b52cbb5a08f20c.tar.gz
Allow users of gprof to get per run output files (using the pid)
PR: bin/99800 Submitted by: Peter Jeremy <peterjeremy@optushome.com.au> Reviewed by: jilles (code) Reviewed by: dwhite (doc) Approved by: cperciva MFC after: 1 week
Diffstat (limited to 'lib/libc/gmon/gmon.c')
-rw-r--r--lib/libc/gmon/gmon.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c
index edf4e2f..8f508b0 100644
--- a/lib/libc/gmon/gmon.c
+++ b/lib/libc/gmon/gmon.c
@@ -157,7 +157,12 @@ _mcleanup(void)
}
moncontrol(0);
- snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
+ if (getenv("PROFIL_USE_PID"))
+ snprintf(outname, sizeof(outname), "%s.%d.gmon",
+ _getprogname(), getpid());
+ else
+ snprintf(outname, sizeof(outname), "%s.gmon", _getprogname());
+
fd = _open(outname, O_CREAT|O_TRUNC|O_WRONLY, 0666);
if (fd < 0) {
_warn("_mcleanup: %s", outname);
OpenPOWER on IntegriCloud