Listen on a socket for gdb to connect to.
[riscv-isa-sim.git] / spike_main / termios-xspike.cc
1 // See LICENSE for license details.
2
3 // termios-xspike sets up a canonical terminal and blocks forever.
4 // It allows us to send Ctrl-C etc. to the target machine.
5
6 #include <unistd.h>
7 #include <termios.h>
8 #include <signal.h>
9 #include <assert.h>
10 #include <stdlib.h>
11 #include <stdio.h>
12
13 int main()
14 {
15 struct termios old_tios;
16 if (tcgetattr(0, &old_tios) < 0)
17 return -1;
18
19 signal(SIGTERM, [](int) { });
20
21 struct termios new_tios = old_tios;
22 new_tios.c_lflag &= ~(ICANON | ECHO | ISIG);
23 if (tcsetattr(0, TCSANOW, &new_tios) < 0)
24 return -1;
25
26 pause();
27
28 return tcsetattr(0, TCSANOW, &old_tios);
29 }