Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: fork() interferring with backtick

by Eily (Hermit)
on Oct 16, 2013 at 16:29 UTC ( #1058494=note: print w/ replies, xml ) Need Help??


in reply to fork() interferring with backtick

why would the fork() interfere with the results from the backticks in line 8?
It probably doesn't, it's too late for that (you already have the ouput of your system call by the time fork is called). What do you call "not working"? Do you have an error displayed, does your program skip certain files?

If the issue is that your list is not processed in the right order, then it's because you can't predict the order in which processes will be run. And if you're going to wait for one iteration of the loop to be over before doing the next, then fork is of no use.

If the order really is not important, then your processes are probably trying to access the same resource at the same time.


Comment on Re: fork() interferring with backtick
Re^2: fork() interferring with backtick
by mkaiser67 (Initiate) on Oct 16, 2013 at 18:30 UTC
    Specifically the backtick command line finds a list of .makelist files in the subdirectories of $dir - hence the array @makelists. What I am finding is the fork call truncates the @makelists in some cases, but repeatably in the same spot for particular directory calls. i know this by adding a print $makelist."\n", just before the ProcessMakeList call. however if i move the fork call before the backtick command the array is preserved.
      If output from external command is truncated, maybe it's this bug (in perl 5.14 ):
      https://rt.perl.org/rt3/Ticket/Display.html?id=119097
      http://www.perlmonks.org/?node_id=1026468

      i.e. data received from pipe can be truncated if SIGnal received (and you have signal handler, thus you are affected). I suggest check $! after backtricks call.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1058494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-08-30 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls