Convert atexit users to exit_notifier

All of these users have global state so we really don't see a benefit from
exit_notifier.  However, using exit_notifier means that there's one less
justification for having global state in the first place.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Anthony Liguori 2010-03-17 17:59:26 -05:00
parent 3b6304f706
commit d7234f4d7e
8 changed files with 26 additions and 12 deletions

View file

@ -713,9 +713,15 @@ static void term_exit(void)
fcntl(0, F_SETFL, old_fd0_flags);
}
static void term_exit_notifier(Notifier *notifier)
{
term_exit();
}
static void term_init(QemuOpts *opts)
{
struct termios tty;
static Notifier exit_notifier = { .notify = term_exit_notifier };
tcgetattr (0, &tty);
oldtty = tty;
@ -735,8 +741,9 @@ static void term_init(QemuOpts *opts)
tcsetattr (0, TCSANOW, &tty);
if (!term_atexit_done++)
atexit(term_exit);
if (!term_atexit_done++) {
exit_notifier_add(&exit_notifier);
}
fcntl(0, F_SETFL, O_NONBLOCK);
}