aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnssi Hannula <anssi@mandriva.org>2010-01-03 11:51:18 +0000
committerAnssi Hannula <anssi@mandriva.org>2010-01-03 11:51:18 +0000
commit75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc (patch)
tree9271176f41aea62dce541d0a08aea388dc84d22f
parentf2f95e45da4e754fc7a2807f9cbeb63665342620 (diff)
downloadmonitor-edid-75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc.tar
monitor-edid-75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc.tar.gz
monitor-edid-75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc.tar.bz2
monitor-edid-75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc.tar.xz
monitor-edid-75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc.zip
monitor-get-edid-using-vbe:
add basic 15 sec timeout, with --no-timeout for disabling it
-rw-r--r--NEWS1
-rw-r--r--monitor-get-edid-using-vbe.c18
2 files changed, 18 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 505c945..e777147 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,7 @@
o never retry in console mode if the card reports that the port does
not support DDC (usually this means that the port has no display
devices connected)
+ o add basic 15 sec timeout, with --no-timeout for disabling it
- monitor-parse-edid:
o print EDID version and the number of EDID extension blocks
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) {