Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IPC::Run with timeouts results in Modification of a read-only value error

Tags:

perl

I'm using IPC::Run with timeouts and I am getting an odd error: Modification of a read-only value attempted at ${HOME}/perl5/lib/perl5/IPC/Run.pm line 1693.

use strict;
use warnings;
use IPC::Run qw(timeout);
​
my $job_command = '/bin/ls';
my $timeout_value = 20;
my $t = timeout($timeout_value);
IPC::Run::run($job_command, undef, undef, undef, $t);

Anyone have experience w/ this?

Edited to add that this is the results w/ perl v5.16.3 and v5.22.0 w/ IPC::Run version 20200505.0

like image 330
SparkeyG Avatar asked Nov 20 '25 07:11

SparkeyG


1 Answers

undef is not a valid argument.

Simply use

IPC::Run::run($job_command, $t);

Test:

use IPC::Run qw( run timeout );

run([ 'perl', '-e', 'sleep' ], timeout(5));

Output:

IPC::Run: timeout on timer #1 at /home/ikegami/usr/perlbrew/perls/5.32.0t/lib/site_perl/5.32.0/IPC/Run.pm line 2951.
like image 177
ikegami Avatar answered Nov 21 '25 23:11

ikegami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!