curses: don't initialize curses when qemu is daemonized
PATCH v2 1/1 curses: don't initialize curses when qemu is daemonized
Current qemu initializes curses even if -daemonize option is passed. This cause problem because shell prompt appears without calling endwin().
This patch adds new function, is_daemonized(), to OS dependent code. With this function, curses_display_init() can check that qemu is daemonized or not. If daemonized, curses_display_init() isn't called and the problem is avoided.
Of course, -daemonize && -curses doesn't make sense. Users shouldn't pass the arguments at the same time. But the problem is very painful because Ctrl-C cannot be delivered to the terminal.
---
v2: is_daemonized() is now called in main(), not in curses_display_init()
8<---
os-posix.c | 5 +++++ qemu-os-posix.h | 2 ++ qemu-os-win32.h | 5 +++++ vl.c | 3 ++- 4 files changed, 14 insertions(+), 1 deletions(-)
os-posix.c +5 -0
@@ -360,3 +360,8 @@ int qemu_create_pidfile(const char *filename)/* keep pidfile open & locked forever */ return 0 ; } + +int is_daemonized (void ) +{ +return daemonize; +}
qemu-os-posix.h +2 -0
@@ -46,4 +46,6 @@ typedef struct timeval qemu_timeval;typedef struct timespec qemu_timespec ;int qemu_utimens (const char *path,const qemu_timespec *times); +int is_daemonized (void ); +#endif
qemu-os-win32.h +5 -0
@@ -86,4 +86,9 @@ typedef struct { } qemu_timeval;int qemu_gettimeofday (qemu_timeval *tp); +static inline int is_daemonized (void ) +{ +return 0 ; +} +#endif
vl.c +2 -1
@@ -3657,7 +3657,8 @@ int main(int argc, char **argv, char **envp)break ;#if defined(CONFIG_CURSES )case DT_CURSES : -curses_display_init (ds, full_screen); +if (!is_daemonized ()) +curses_display_init (ds, full_screen);break ;#endif #if defined(CONFIG_SDL )
Signature · 1 line
1.7.5.1
Stefan Hajnoczi
AppliedQuoted 20 lines · Hitoshi Mitake
Current qemu initializes curses even if -daemonize option is passed. This cause problem because shell prompt appears without calling
endwin().This patch adds new function,
is_daemonized(), to OS dependent code. With this function,curses_display_init()can check that qemu is daemonized or not. If daemonized,curses_display_init()isn't called and the problem is avoided.Of course, -daemonize && -curses doesn't make sense. Users shouldn't pass the arguments at the same time. But the problem is very painful because Ctrl-C cannot be delivered to the terminal.
Cc Andrzej Zaborowski <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Anthony Liguori <[email protected]>Cc Michael Roth <[email protected]>Signed-off-by Hitoshi Mitake <[email protected]>---
Quoted 8 lines
v2:
is_daemonized()is now called inmain(), not incurses_display_init()8<---
os-posix.c | 5 +++++ qemu-os-posix.h | 2 ++ qemu-os-win32.h | 5 +++++ vl.c | 3 ++- 4 files changed, 14 insertions(+), 1 deletions(-)
There has been no further discussion so this patch is ready to go. I have fixed up the coding style issues - please use scripts/checkpatch.pl next time (and see ./CODING_STYLE and ./HACKING).
Thanks, applied to the trivial patches tree:
https://github.com/stefanha/qemu/commits/trivial-patches
Stefan
Quoted 30 lines · Stefan Hajnoczi
Quoted 20 lines · Hitoshi Mitake
Current qemu initializes curses even if -daemonize option is passed. This cause problem because shell prompt appears without calling
endwin().This patch adds new function,
is_daemonized(), to OS dependent code. With this function,curses_display_init()can check that qemu is daemonized or not. If daemonized,curses_display_init()isn't called and the problem is avoided.Of course, -daemonize && -curses doesn't make sense. Users shouldn't pass the arguments at the same time. But the problem is very painful because Ctrl-C cannot be delivered to the terminal.
Cc Andrzej Zaborowski <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Anthony Liguori <[email protected]>Cc Michael Roth <[email protected]>Signed-off-by Hitoshi Mitake <[email protected]>---
Quoted 8 lines
v2:
is_daemonized()is now called inmain(), not incurses_display_init()8<---
os-posix.c | 5 +++++ qemu-os-posix.h | 2 ++ qemu-os-win32.h | 5 +++++ vl.c | 3 ++- 4 files changed, 14 insertions(+), 1 deletions(-)
Quoted 3 lines
There has been no further discussion so this patch is ready to go. I have fixed up the coding style issues - please use
scripts/checkpatch.plnext time (and see ./CODING_STYLE and ./HACKING).
Sorry for my coding style problems and thanks for your fix!
Thanks,
Hitoshi