This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcov can't collect data when process is executed by systemctl start but it can when executed by ./process


On 2017-07-31 14:05 +0200, Toebs Douglass wrote:
> On 31/07/17 13:04, Xi Ruoyao wrote:
> > By using exit(), the functions registered by atexit() and on_exit() would be
> > called.  GCC registers one atexit function to produce .gcda file.
> 
> Yups.  I have run into this problem in the past, too; a coveraged binary
> must exit() to generate coverage output.
> 
> > Even if without gcov, it's recommended to catch SIGTERM and terminate your
> > service cleanly.
> 
> What!
> 
> I didn't know this.
> 
> But you can't *do* anything much in a signal handler, no?

No we can't.  Normally it's just

bool is_terminating = false;

void handler(int signum)
{
  is_terminating = true;
}

And let the normal code (outside signal context) detect is_terminating, do some
clean up, and exit.
-- 
Xi Ruoyao <ryxi@stu.xidian.edu.cn>
School of Aerospace Science and Technology, Xidian University


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]