From 75dc2ecd455b85e78aaa77212cb33eeb7ffb74bc Mon Sep 17 00:00:00 2001 From: Anssi Hannula Date: Sun, 3 Jan 2010 11:51:18 +0000 Subject: monitor-get-edid-using-vbe: add basic 15 sec timeout, with --no-timeout for disabling it --- NEWS | 1 + monitor-get-edid-using-vbe.c | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) 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 #include #include +#include #include #include #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) { -- cgit v1.2.1