On Thu, 18 Feb 2016, Jon Turney wrote:
On 18/02/2016 11:29, Mark Geisert wrote:
A brief search tells me that apparently glibc supports the
(undocumented) GMON_OUT_PREFIX env var which enables a similar behaviour.
Ah, I did not know about that. It would be easy to implement.
So I'm leaning towards choosing file name as GMON_OUT_PREFIX.exename.pid
with GMON_OUT_PREFIX defaulting to "gmon.out" if unspecified.
I think if you are going to implement GMON_OUT_PREFIX, you should make the
behaviour the same as glibc.
Do you think the expanded name should be used in all cases, or only when
there's a gmon.out already present?
I don't think you should be checking for an existing gmon.out file. In the
simple case where the program doesn't fork, it's expected that gmon.out will
get overwritten.
OK, so the file name would be "gmon.out" if GMON_OUT_PREFIX is not
specified, and $GMON_OUT_PREFIX.$pid if it is. And don't check for
existing files in either case.
I was also worried about a profiled program fork/exec'ing a different
profiled program and so I considered having $exename be part of the
file name. But I now think following the undocumented glibc behavior is
better in the long run. One can arrange a different GMON_OUT_PREFIX for
the execee if that's truly necessary.
Thanks; I appreciate the feedback.
..mark