in reply to Re^4: Behavior of threads on XP-- system() works, backtic & popen don't...
in thread Behavior of threads on XP-- system() works, backtic & popen don't...

I can't reproduce your errors. My feeling is that the errors you are describing are so obvious that they would have been seen and reported long ago if this were a problem with Perl or AS perl. That leads me to conclude that the problem is something to do with your own environment.

You will need to produce a short script that reliably reproduces the problems for other people before you will be able to take this further.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: Behavior of threads on XP-- system() works, backtic & popen don't...

Replies are listed 'Best First'.
Re^6: Behavior of threads on XP-- system() works, backtic & popen don't...
by Sync (Initiate) on Jun 16, 2006 at 17:23 UTC
    Well, I don't know what to say at this point-- so far I've tried it on FIVE different machines of various sorts, all XP but both SP1 & SP2, hyperthreading and not, laptops and desktops, Intel & AMD CPUs, from 866MHZ to 2.8GHZ, and they all readily exhibit the problem. I can come up to a machine, install the AS817 .msi with all the default installation options, then open a dos window and run the .bat test loop above and it will hang in short order, sometimes immediately but always within a small number of iterations. I've yet to find a machine where it DOESN'T happen. I'm running out of machines to test it on... -- Sync

      Perhaps if you posted the exact code that you are testing with, rather than a vague description of a vague starting point, then I might see why my attempts to reproduce your code from your descriptions doesn't hang and yours does.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        The exact code is in Re:^2.

        But to be even more exact, the data I put in the test dat files is exactly two lines:

        world
        hello

        Though I tried a 1-9 approach as you did in Re:^3 and it didn't change the result. And the exact .bat script for looping the test until it hangs is also in Re:^2:

        LOOP: perl thread2.pl goto LOOP

        On 3 out of 5 machines I tried it hangs immediately just after the first output of the system() results of the threads, on the other two machines it loops a few times then hangs at various points. On those machines it takes less than 60 seconds to produce a hang. -- Sync

      update Overtaken by OP's additional info in thread above. NO <strike>...</strike> as the observation may tickle a neuron in another monk, someday.
      Given BrowserUK 's yeoman attempts to help you, you might consider that the known, common factor on all five machines is the code you wrote. That, it seems to me, makes it worthwhile to check that code carefully... and to be sure what you showing in your OP is still relevant.

        I appreciate that BrowserUK is attempting to help, I'm not knocking that at all (yes-- thank you VERY MUCH BrowserUK). As I just posted in my reply to him-- the Re^2 code is exactly what I'm using to test with:

        #! perl -slw use strict; use threads; sub test { my $t = shift; my $cmd = "c:/windows/system32/sort.exe test$t.dat"; print "Thread $t\n"; # show things are in motion... sleep 1; # kludge to insure all threads are up... system "$cmd >sorted$t.dat"; open F, "<sorted$t.dat" or die $!; print "Via system:\n", do{ local $/; <F> }; close F; print "Via backticks\n", `$cmd`; open F, "$cmd|" or die $!; print "Via pipe\n", <F>; close F; } sub spawnem { my $t1 = async{ \&test(1); }; my $t2 = async{ \&test(2); }; my $t3 = async{ \&test(3); }; my $t4 = async{ \&test(4); }; $t1->join; $t2->join; $t3->join; $t4->join; } &spawnem;

        The test1-4.dat files all contain the same two lines

        world
        hello

        And I loop the test from the DOS shell with the following .bat script:

        LOOP: perl thread2.pl goto LOOP

        A typical output I get when it hangs immediately looks like this:

        Thread 1 Thread 2 Thread 3 Thread 4 Via system: hello world

        where it just sits there and hangs until I ctl-C.

        It'd be nice if the problem is a bug in my code, but I had started originally with a larger example and BrowserUK neatly reduced it to a short little thing that worked for him but didn't run multiple threads in parallel. So I modified it so that it would and that's where the code came from. Again, I may have introduced a bug and if so I'd sure like to know where my conception of how threads works is faulty...

        -- Sync