in reply to Re^2: Ulimit makes program hang
in thread Ulimit makes program hang

Hi ,

I strongly suspect that, if you re-insert the sleep before shelling out, your results will be modified since the perl process won't otherwise have enough time to complete the print.

Have you tried the fork/exec approach ?

Have you tried an even lower limit and running the program using truss (or is it strace on linux) ?

As an afterthought, I do wonder if you've uncovered a bug in perl...

A user level that continues to overstate my experience :-))

Replies are listed 'Best First'.
Re^4: Ulimit makes program hang
by memo2005 (Initiate) on Aug 13, 2008 at 15:50 UTC
    After insterting sleep before shelling out I get exactly same results.

    I'm not a system programmer to analyse strace output...sorry.

    I have tried fork and exec this way:
    #!/usr/bin/perl -w my $x = $ARGV[0] + 1; print STDERR "$x\n"; if (!defined($child_pid = fork())) { die "cannot fork: $!"; } elsif ($child_pid) { waitpid($child_pid, 0); } else { exec "$0 $x"; }
    This program never hangs -- always says cannot fork: Resource temporarily unavailable at ./fork_wait line 7.
    But I must grab output of command so I can't use this solution.
      ...as I suspected, using the evidence of your OP and this posting, I think you've got enough to raise a perl bug against the backtick (``) operator - I think it should die with a similar fatal error.

      Section 16 of the Perl Cookbook should provide you with some background in order to progress further with capturing output from a command ...

      HTH ,

      A user level that continues to overstate my experience :-))