mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-22 15:26:21 +00:00
testdisplay: fix restoring termio at exit
At normal exit in test_all_modes we don't restore the original termio, since g_io_channel_shutdown() closes the stdin fd and so the following tcsetattr on stdin will fail. We also don't restore the termio at signal exit. Fix both cases by installing an exit hanlder with a dup'ed stdin fd. Signed-off-by: Imre Deak <imre.deak@intel.com>
This commit is contained in:
parent
d848a36545
commit
63746417e2
@ -71,6 +71,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
static int tio_fd;
|
||||||
struct termios saved_tio;
|
struct termios saved_tio;
|
||||||
|
|
||||||
drmModeRes *resources;
|
drmModeRes *resources;
|
||||||
@ -698,9 +699,6 @@ static void __attribute__((noreturn)) usage(char *name)
|
|||||||
static void cleanup_and_exit(int ret)
|
static void cleanup_and_exit(int ret)
|
||||||
{
|
{
|
||||||
close(drm_fd);
|
close(drm_fd);
|
||||||
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);
|
|
||||||
|
|
||||||
exit(ret);
|
exit(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -738,19 +736,22 @@ static void enter_exec_path( char **argv )
|
|||||||
free(exec_path);
|
free(exec_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void restore_termio_mode(int sig)
|
||||||
|
{
|
||||||
|
tcsetattr(tio_fd, TCSANOW, &saved_tio);
|
||||||
|
close(tio_fd);
|
||||||
|
}
|
||||||
|
|
||||||
static void set_termio_mode(void)
|
static void set_termio_mode(void)
|
||||||
{
|
{
|
||||||
struct termios tio;
|
struct termios tio;
|
||||||
|
|
||||||
tcgetattr(STDIN_FILENO, &saved_tio);
|
tio_fd = dup(STDIN_FILENO);
|
||||||
|
tcgetattr(tio_fd, &saved_tio);
|
||||||
|
igt_install_exit_handler(restore_termio_mode);
|
||||||
tio = saved_tio;
|
tio = saved_tio;
|
||||||
|
|
||||||
tio.c_lflag &= ~(ICANON | ECHO);
|
tio.c_lflag &= ~(ICANON | ECHO);
|
||||||
|
tcsetattr(tio_fd, TCSANOW, &tio);
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &tio);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
@ -899,7 +900,5 @@ out_mainloop:
|
|||||||
out_close:
|
out_close:
|
||||||
close(drm_fd);
|
close(drm_fd);
|
||||||
|
|
||||||
tcsetattr(STDIN_FILENO, TCSANOW, &saved_tio);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user