2013-10-17 2 views
0

timeout_system 모듈을 설치하려고합니다. 나는 창문에있다. 시도하면설치하는 시스템 System :: Timeout qw (timeout);

cpanm System::Timeout 

실패합니다. 내가

CPAN 시스템 : 제한 시간

을하려고하면

나는 사람이 아이디어가있는 경우

C:\Windows\System32>cpan System:Timeout 
CPAN: LWP::UserAgent loaded ok (v6.03) 
Fetching with LWP: 
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz 
CPAN: YAML loaded ok (v0.77) 
CPAN: CPAN::SQLite loaded ok (v0.202) 
Fetching with LWP: 
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz 
Fetching with LWP: 
http://cpan.strawberryperl.com/modules/03modlist.data.gz 
Database was generated on Mon, 16 Sep 2013 20:14:09 GMT 
Updating database file ... 
Done!Running install for module 'System::Timeout' 
Running make for C/CH/CHENGANG/System-Timeout-0.07.tar.gz 
Fetching with LWP: 
http://cpan.strawberryperl.com/authors/id/C/CH/CHENGANG/System-Timeout-0.07.tar.gz 
CPAN: Digest::SHA loaded ok (v5.63) 
Fetching with LWP: 
http://cpan.strawberryperl.com/authors/id/C/CH/CHENGANG/CHECKSUMS 
CPAN: Compress::Zlib loaded ok (v2.042) 
Checksum for C:\Dwimperl\cpan\sources\authors\id\C\CH\CHENGANG\System-Timeout- 0.07.tar.gz ok 
CPAN: Archive::Tar loaded ok (v1.80) 
CPAN: File::Temp loaded ok (v0.22) 
CPAN: Parse::CPAN::Meta loaded ok (v1.4401) 
CPAN: CPAN::Meta loaded ok (v2.120351) 
CPAN: Module::CoreList loaded ok (v2.57) 

    CPAN.pm: Building C/CH/CHENGANG/System-Timeout-0.07.tar.gz 

Checking if your kit is complete... 
Looks good 
Writing Makefile for System::Timeout 
Writing MYMETA.yml and MYMETA.json 
cp lib/System/Timeout.pm blib\lib\System\Timeout.pm 
C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- bin/timeout blib\script\timeout 
pl2bat.bat blib\script\timeout 
    CHENGANG/System-Timeout-0.07.tar.gz 
    C:\Dwimperl\c\bin\dmake.EXE -- OK 
Running make test 
C:\Dwimperl\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib\lib', 'blib\arch')" t/*.t 
t/00System-Timeout.t .. 1/9 'sleep' is not recognized as an internal or external command, 
operable program or batch file. 
'sleep' is not recognized as an internal or external command, 
operable program or batch file. 
Can't find string terminator "'" anywhere before EOF at -e line 1. 

# Failed test 'system timeout exit code' 
# at t/00System-Timeout.t line 21. 
Can't find string terminator "'" anywhere before EOF at -e line 1. 

# Failed test 'timeout timeout exit code' 
# at t/00System-Timeout.t line 27. 
# Looks like you failed 2 tests of 9. 
t/00System-Timeout.t .. Dubious, test returned 2 (wstat 512, 0x200) 
Failed 2/9 subtests 
t/01bin-timeout.t ..... '..' is not recognized as an internal or external command, 
operable program or batch file. 
t/01bin-timeout.t ..... 1/4 '..' is not recognized as an internal or external command, 
operable program or batch file. 

# Failed test 'bin-timeout exit code' 
# at t/01bin-timeout.t line 15. 
# Looks like you failed 1 test of 4. 
t/01bin-timeout.t ..... Dubious, test returned 1 (wstat 256, 0x100) 
Failed 1/4 subtests 

Test Summary Report 
------------------- 
t/00System-Timeout.t (Wstat: 512 Tests: 9 Failed: 2) 
    Failed tests: 7, 9 
    Non-zero exit status: 2 
t/01bin-timeout.t (Wstat: 256 Tests: 4 Failed: 1) 
    Failed test: 4 
    Non-zero exit status: 1 
Files=2, Tests=13, 1 wallclock secs (0.09 usr + 0.05 sys = 0.14 CPU) 
Result: FAIL 
Failed 2/2 test programs. 3/13 subtests failed. 
dmake.EXE: Error code 129, while making 'test_dynamic' 
    CHENGANG/System-Timeout-0.07.tar.gz 
    C:\Dwimperl\c\bin\dmake.EXE test -- NOT OK 
//hint// to see the cpan-testers results for installing this module, try: 
    reports CHENGANG/System-Timeout-0.07.tar.gz 
Running make install 
    make test had returned bad status, won't install without force 

C:\Windows\System32>ppm Par-Packer 

, 즉 도움이 될 것입니다 얻을. Perl에 모듈을 설치하는 데 너무 많은 경험이 없기 때문에 timeout_system을 사용하는 것이 좋습니다.

들으

업데이트 : 작동

   my $pid = fork(); 

       if (!$pid) { 
        exec($command);    
       } 

       else { 
        sleep 100;       
        system("TASKKILL /F /T /PID $$"); 
       } 

을 : 나는 다음과 같이가는 끝났다.

+2

이 모듈 창에 CPANTesters에는 패스가 없습니다. 그것은 창문에서 작동하도록 설계되지 않은 것 같습니다. 대체 모듈에 대해서는 POD의 "참조"를 참조하십시오. – toolic

답변

3

Windows에서의 포킹이 * NIX 시스템에서와 같이 작동하지 않는다면, 변경없이 Windows에서 작동한다고 생각하지 않습니다. 설치 및 CPAN을 통해 종속 모듈 IPC :: cmd를 테스트하고 CPAN 워드 프로세서의 샘플 스크립트를 실행하면 다음과 같은 결과를 생산 ...

c:\Perl>perl TEST_IPC_Cmd.pl 
Set up gcc environment - 3.4.5 (mingw-vista special r3) 
fetched webpage successfully: Continuing in background, pid 5244. 
Output will be written to `wget-log.2'. 

this is what the command printed: 
Continuing in background, pid 5796. 
Output will be written to `wget-log.3'. 
run_forked is not available: at TEST_IPC_Cmd.pl line 30. 
IPC::Open3 available: 1.12IPC::Run available: Can capture buffer: 1 
c:\Perl> 

시스템 : 제한 시간 종료는 IPC 주위 그냥 아주 간단한 래퍼이기 때문에 : : Cmd run 메서드 (timeout 속성도 설정), IPC :: Cmd 모듈은 System :: Timeout이 예상대로 작동하기 전에 먼저 Windows에서 올바르게 실행되도록 수정해야합니다.

필자의 경우 IPC :: Cmd를 설치 한 후 수동으로 System :: Timeout을 설치하면 실행 파일 (Perl 한 라이너)이 성공적으로 시작되었지만 3 초 후에 프로세스가 종료되지 않았습니다.

#Perl_AAA.pl 
use System::Timeout qw(timeout); 
print localtime()."\n"; 
timeout('perl -e "sleep(9); print \"Done\n\";"'); # invoke CORE::system, will not timeout exit 
print localtime()."\n"; 
timeout("3", 'perl -e "sleep(9); print \"Done\n\";"'); # timeout exit after 3 seconds 
print localtime()."\n"; 
print "Normal exit\n"; 
exit; 

결과 ...

c:\Perl> 
c:\Perl>perl TEST_AAA.pl 
Thu Oct 17 12:51:22 2013 
Done 
Thu Oct 17 12:51:31 2013 
Running [perl -e "sleep(9); print \"Done\n\";"]... 
Done 
Thu Oct 17 12:51:40 2013 
Normal exit 

c:\Perl> 
+0

Windows에서 시간 초과하는 쉬운 방법이 있습니까? – user86895

+0

이 모듈은 CPAN을 만들지 못했지만 여기에서 개발을 시작한 Windows 특정 시간 초과 모듈을 살펴보십시오. http://www.perlmonks.org/bare/?node_id=90316 –