mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-04-27 11:22:17 +00:00
dm: uart: add escape sequence Ctrl-a x to exit dm
When guest console is redirected to stdio, Ctrl-c is also passed to guest. Add escape sequence Ctrl-a x to send SIGINT to exit acrn-dm in such case. Tracked-On: #8731 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com> Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
This commit is contained in:
parent
dbc3ff39aa
commit
8aca9eb12f
@ -29,6 +29,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
@ -94,6 +95,8 @@ static struct {
|
||||
{ COM5_BASE, COM5_IRQ, false},
|
||||
};
|
||||
|
||||
static bool stdio_ctrl_a_pressed = false;
|
||||
|
||||
#define UART_NLDEVS (ARRAY_SIZE(uart_lres))
|
||||
|
||||
enum uart_be_type {
|
||||
@ -717,6 +720,18 @@ uart_backend_read(struct uart_backend *be)
|
||||
|
||||
switch (be->be_type) {
|
||||
case UART_BE_STDIO:
|
||||
rc = read(be->fd, &rb, 1);
|
||||
if (rb == 0x01) { // Ctrl-a
|
||||
DPRINTF(("%s: Got Ctrl-a\n", __func__));
|
||||
stdio_ctrl_a_pressed = true;
|
||||
} else if (stdio_ctrl_a_pressed) {
|
||||
if (rb == 'x') {
|
||||
DPRINTF(("%s: Got Ctrl-a x\n", __func__));
|
||||
kill(getpid(), SIGINT);
|
||||
}
|
||||
stdio_ctrl_a_pressed = false;
|
||||
}
|
||||
break;
|
||||
case UART_BE_TTY:
|
||||
/* fd is used to read */
|
||||
rc = read(be->fd, &rb, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user