Profiling after exit()

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 27 23:32:59 PDT 2017


On 2017-07-27 16:30, Eugene Wissner wrote:
> I have a multi-threaded application, whose threads normally run forever. 
> But I need to profile this program, so I compile the code with -profile, 
> send a SIGTERM and call exit(0) from my signal handler to exit the 
> program. The problem is that I get the profiling information only from 
> the main thread, but not from the other ones.
> 
> Is there a way to get the profiling information from all threads before 
> terminating the program? Maybe some way to finish the threads 
> gracefully? or manully call "write trace.log"-function for a thread?

As others have mentioned, you should in general avoid calling "exit" in 
a D program. There's a C function called "atexit" that allows to 
register a callback that is called after calling "exit". You could 
perhaps join the threads there. I don't know if that helps with the 
profiling though.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list