aboutsummaryrefslogtreecommitdiffstats
path: root/monitor-get-edid-using-vbe.c
diff options
context:
space:
mode:
Diffstat (limited to 'monitor-get-edid-using-vbe.c')
-rw-r--r--monitor-get-edid-using-vbe.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/monitor-get-edid-using-vbe.c b/monitor-get-edid-using-vbe.c
index 0ba76dd..f922a6b 100644
--- a/monitor-get-edid-using-vbe.c
+++ b/monitor-get-edid-using-vbe.c
@@ -7,18 +7,27 @@
#include <fcntl.h>
#include <errno.h>
#include <stdarg.h>
+#include <signal.h>
#include <sys/ioctl.h>
#include <sys/vt.h>
#include "get-edid.h"
int verbose = 0;
+static void timeout_handler(int signal)
+{
+ fprintf(stderr, "ERROR: timeout during EDID probe\n");
+ exit(1);
+}
+
int main(int argc, char **argv)
{
+ struct sigaction timeout_action;
char edid[(1 + MAX_EXTENSION_COUNT) * EDID_BLOCK_SIZE];
int try_in_console = 0;
int skip_vbe_check = 0;
int port = 0;
+ int no_timeout = 0;
int i;
for (i = 1; i < argc; i++) {
@@ -27,14 +36,21 @@ int main(int argc, char **argv)
else if (strcmp(arg, "--port") == 0 && i+1 < argc) port = atoi(argv[++i]);
else if (strcmp(arg, "--try-in-console") == 0) try_in_console = 1;
else if (strcmp(arg, "--skip-vbe-check") == 0) skip_vbe_check = 1;
+ else if (strcmp(arg, "--no-timeout") == 0) no_timeout = 1;
else if (strcmp(arg, "-h") == 0 ||
strcmp(arg, "--help") == 0) {
printf("usage: monitor-get-edid [-v] [--port <0-3>] [--try-in-console]\n"
- " [--skip-vbe-check]\n");
+ " [--skip-vbe-check] [--no-timeout]\n");
exit(1);
}
}
+ if (!no_timeout) {
+ timeout_action.sa_handler = timeout_handler;
+ sigaction(SIGALRM, &timeout_action, NULL);
+ alarm(15);
+ }
+
int size = get_edid(edid, port, skip_vbe_check);
if (size < 0 && try_in_console) {