Professional Web Applications Themes

loop using backticks stalls after ~30x - PERL Beginners

Hi, I'm trying to repeatedly call some external program from Perl using backticks. This works fine for ~30 rounds, but then the program stops doing anything, with a <defunct> process hanging around (apparently Perl ignores its dead child?). A simple example is this: #!/usr/bin/perl for (my $j=0;$j<10000;$j++) { my $result = `ls` ; print $result ; }   2740 pts/7 S 0:00 \_ /usr/bin/perl ./t5.pl 2894 pts/7 T 0:00 \_ ls 2895 pts/7 Z 0:00 \_ [ls <defunct>] Any suggestion as to what's going on? Any way to avoid this? [This is Perl 5.8.0 under Linux] Cheers, Martin...

  1. #1

    Default loop using backticks stalls after ~30x

    Hi,

    I'm trying to repeatedly call some external program from Perl using
    backticks. This works fine for ~30 rounds, but then the program stops
    doing anything, with a <defunct> process hanging around (apparently Perl
    ignores its dead child?). A simple example is this:

    #!/usr/bin/perl
    for (my $j=0;$j<10000;$j++) {
    my $result = `ls` ;
    print $result ;
    }
     
    2740 pts/7 S 0:00 \_ /usr/bin/perl ./t5.pl
    2894 pts/7 T 0:00 \_ ls
    2895 pts/7 Z 0:00 \_ [ls <defunct>]


    Any suggestion as to what's going on? Any way to avoid this?
    [This is Perl 5.8.0 under Linux]

    Cheers,
    Martin


    Martin Guest

  2. #2

    Default Re: loop using backticks stalls after ~30x

    Martin Lercher wrote: 
    > 2740 pts/7 S 0:00 \_ /usr/bin/perl ./t5.pl
    > 2894 pts/7 T 0:00 \_ ls
    > 2895 pts/7 Z 0:00 \_ [ls <defunct>][/ref]

    I don't think that is Perl; the OpSys is
    responsible for cleaning up zombies...

    Besides, this code work fine under
    Solaris 9 with 1GB RAM.

    -Sx-

    Wc Guest

  3. #3

    Default Re: loop using backticks stalls after ~30x

    On Fri, 02 Apr 2004 16:22:51 +0200
    Martin Lercher <ac.uk> wrote:
     
    > 2740 pts/7 S 0:00 \_ /usr/bin/perl ./t5.pl
    > 2894 pts/7 T 0:00 \_ ls
    > 2895 pts/7 Z 0:00 \_ [ls <defunct>][/ref]

    Strange. It looks like ls has forked a copy of itself and is waiting
    for input or waiting to send output to the terminal or has been stopped.
    That is what the 'T' means in the ps listing.

    Are you sure you are executing /bin/ls and not some other ls program in
    your PATH? Try doing an strace on the stopped process and see where it
    stopped.

    --
    Smoot Carl-Mitchell
    Systems/Network Architect
    email: com
    cell: +1 602 421 9005
    home: +1 480 922 7313
    Smoot Guest

Similar Threads

  1. #39722 [NEW]: PHP-CGI process stalls
    By shri_phadte at yahoo dot co dot in in forum PHP Bugs
    Replies: 3
    Last Post: December 5th, 12:50 PM
  2. XML connector stalls
    By metStevo in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: October 10th, 07:11 PM
  3. Shockwave stalls on One site only.
    By Xela1 in forum Macromedia Shockwave
    Replies: 2
    Last Post: August 2nd, 05:16 PM
  4. web page stalls after macromedia logo
    By taheal in forum Macromedia Director Basics
    Replies: 0
    Last Post: November 29th, 06:24 AM
  5. #23502 [Com]: compiler stalls
    By christophe dot godard at alcatel dot fr in forum PHP Development
    Replies: 0
    Last Post: November 17th, 08:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139