Hi there, If the calling process has SIGALRM blocked, timeout simply never times out.
Find attached a small program to demonstrate the problem and a patch to fix it by unblocking the necessary signal (at least on x86/linux). If this is intended behavior, I would suggest to document it explicitly to prevent people from tapping into the same pitfall that I hit. Greetings Stephan
blocksigalrm.pl
Description: Perl program
diff -Naur coreutils-8.20.orig/src/timeout.c coreutils-8.20/src/timeout.c
--- coreutils-8.20.orig/src/timeout.c 2012-10-23 16:14:12.000000000 +0200
+++ coreutils-8.20/src/timeout.c 2013-01-23 18:40:09.138166579 +0100
@@ -433,6 +433,16 @@
pid_t wait_result;
int status;
+ /* assure our timeout signal SIGALRM is not blocked */
+ sigset_t unblock_set;
+ sigemptyset (&unblock_set);
+ sigaddset (&unblock_set, SIGALRM);
+ if (sigprocmask (SIG_UNBLOCK, &unblock_set, NULL) != 0)
+ {
+ error (0, 0, _("error setting signal mask"));
+ return EXIT_CANCELED;
+ }
+
settimeout (timeout);
while ((wait_result = waitpid (monitored_pid, &status, 0)) < 0
signature.asc
Description: OpenPGP digital signature
