root/debug-testing/testing-alarm.pl @ 31928

Revision 31928, 0.6 KB (checked in by ak19, 3 years ago)

Use of perl alarm() that works on Windows, whereas the use of alarm() in the debug version of WgetDownload?.pm in this folder does not work.

Line 
1#!/usr/bin/perl -w
2
3# See http://www.perlmonks.org/?node_id=1127475
4# http://www.perlmonks.org/?node_id=1127570
5
6# Google: perl open3 windows
7# http://www.perlmonks.org/?node_id=869942
8# http://www.perlmonks.org/?node_id=811650
9# BUT:
10# http://search.cpan.org/~toddr/IPC-Run-0.96/lib/IPC/Run.pm -> http://search.cpan.org/~toddr/IPC-Run-0.96/lib/IPC/Run.pm#Win32_LIMITATIONS
11
12use strict;
13use warnings;
14
15print scalar localtime, "\n";
16
17eval {
18    $SIG{__DIE__} = sub { alarm(0) };
19    $SIG{ALRM} = sub { die "timeout" };
20    alarm(3);
21    sleep 5;
22    alarm(0);
23};
24
25print $@ if $@;
26print scalar localtime, "\n";
Note: See TracBrowser for help on using the browser.