mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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:
parent
3b6304f706
commit
d7234f4d7e
8 changed files with 26 additions and 12 deletions
11
qemu-char.c
11
qemu-char.c
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue