diff mbox series

chardev/char-win-stdio.c: restore old console mode

Message ID ME3P282MB2548B9C3523209F6045785D18CA82@ME3P282MB2548.AUSP282.PROD.OUTLOOK.COM (mailing list archive)
State New, archived
Headers show
Series chardev/char-win-stdio.c: restore old console mode | expand

Commit Message

songziming July 22, 2024, 8:54 a.m. UTC
Hi

I've updated the patch.

Now it only reset mode if handle is valid.

Signed-off-by: Ziming Song <s.ziming@hotmail.com>

---
 chardev/char-win-stdio.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Marc-André Lureau July 22, 2024, 9:28 a.m. UTC | #1
On Mon, Jul 22, 2024 at 1:19 PM songziming <s.ziming@hotmail.com> wrote:

> Hi
>
> I've updated the patch.
>
> Now it only reset mode if handle is valid.
>
>
you lost the commit message, and the subject does not' have a version tag
(see
https://www.qemu.org/docs/master/devel/submitting-a-patch.html#when-resending-patches-add-a-version-tag
)

thanks


> Signed-off-by: Ziming Song <s.ziming@hotmail.com>
>

> ---
>  chardev/char-win-stdio.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c
> index 1a18999..13325ca 100644
> --- a/chardev/char-win-stdio.c
> +++ b/chardev/char-win-stdio.c
> @@ -33,6 +33,7 @@
>  struct WinStdioChardev {
>      Chardev parent;
>      HANDLE  hStdIn;
> +    DWORD   dwOldMode;
>      HANDLE  hInputReadyEvent;
>      HANDLE  hInputDoneEvent;
>      HANDLE  hInputThread;
> @@ -159,6 +160,7 @@ static void qemu_chr_open_stdio(Chardev *chr,
>      }
>
>      is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0;
> +    stdio->dwOldMode = dwMode;
>
>      if (is_console) {
>          if (qemu_add_wait_object(stdio->hStdIn,
> @@ -221,6 +223,9 @@ static void char_win_stdio_finalize(Object *obj)
>  {
>      WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
>
> +    if (stdio->hStdIn != INVALID_HANDLE_VALUE) {
> +        SetConsoleMode(stdio->hStdIn, stdio->dwOldMode);
> +    }
>      if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
>          CloseHandle(stdio->hInputReadyEvent);
>      }
> --
> 2.34.1.windows.1
>
>
>
diff mbox series

Patch

diff --git a/chardev/char-win-stdio.c b/chardev/char-win-stdio.c
index 1a18999..13325ca 100644
--- a/chardev/char-win-stdio.c
+++ b/chardev/char-win-stdio.c
@@ -33,6 +33,7 @@ 
 struct WinStdioChardev {
     Chardev parent;
     HANDLE  hStdIn;
+    DWORD   dwOldMode;
     HANDLE  hInputReadyEvent;
     HANDLE  hInputDoneEvent;
     HANDLE  hInputThread;
@@ -159,6 +160,7 @@  static void qemu_chr_open_stdio(Chardev *chr,
     }
 
     is_console = GetConsoleMode(stdio->hStdIn, &dwMode) != 0;
+    stdio->dwOldMode = dwMode;
 
     if (is_console) {
         if (qemu_add_wait_object(stdio->hStdIn,
@@ -221,6 +223,9 @@  static void char_win_stdio_finalize(Object *obj)
 {
     WinStdioChardev *stdio = WIN_STDIO_CHARDEV(obj);
 
+    if (stdio->hStdIn != INVALID_HANDLE_VALUE) {
+        SetConsoleMode(stdio->hStdIn, stdio->dwOldMode);
+    }
     if (stdio->hInputReadyEvent != INVALID_HANDLE_VALUE) {
         CloseHandle(stdio->hInputReadyEvent);
     }