Opened 6 years ago

Closed 6 years ago

#10843 closed Bug Report - General (Fixed)

SignalHandler does not handle SIGTERM and SIGINT when there is no event loop.

Reported by: danielk Owned by: beirdo
Priority: minor Milestone: 0.26
Component: MythTV - General Version: Master Head
Severity: medium Keywords:
Cc: Ticket locked: no


There are really two problems:

1/ A program like mythcomflag/mythtranscode/mythccextractor won't be running an event loop so the QSocketNotifier will never fire a handleSignal(). This could be addressed by calling QCoreApplication::processEvents() periodically. 2/ If you aren't running in a qApp->exec() then qApp->quit()/qApp->exit(int) doesn't do anything. This could be addressed by setting a static volatile bool when the program should exit and having the program check that after calling QCoreApplication::processEvents().

It might also make sense to set the signal handler to the default within SignalHandler::signalHandler(), then a second SIGKILL or a second SIGINT would kill the program a less elegantly. This would allow routines where forget to add the above to to exit. But we probably wouldn't want to do this right away as we want to identify the places where there is no proper program exit on a signal and not exiting is one way to do that.

Attachments (0)

Change History (3)

comment:1 Changed 6 years ago by Daniel Thor Kristjansson <danielk@…>

In b0473717bdca14e8d4679cda31de17c87b86cd5f/mythtv:

Refs #10843. Adds IsExiting?() call to SignalHandling?.

This allows programs to exit on a signal when they are not in qApp->exec().
They just need to call QCoreApplication::processEvents() and then check
this return value and exit if appropriate.

comment:2 Changed 6 years ago by beirdo

  • Owner changed from bierdo to beirdo
  • Status changed from new to assigned

comment:3 Changed 6 years ago by beirdo

  • Resolution set to Fixed
  • Status changed from assigned to closed

I have also made the code change such that the UNIX handler will remove the handler and set to default on SIGTERM and SIGINT, so that if you are not in an event loop, double Ctrl-C should exit.

I believe this is complete.

Add Comment

Modify Ticket

as closed The owner will remain beirdo.
The resolution will be deleted. Next status will be 'new'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.