Hi, I am fairly new to fork processes. I want to fork a process such that the parent process parses through each file I have in a certain directory and gets the required information and then in a child process submit that acquired information from the file into another module so that it will process that in the background. I am able to do it, however, the last child process is always repeated so I end up with two outputs for that parent file that are exactly the same. Here is a snippet of the code I use to fork the process. Let me know if there is an error in the code that makes it repeat the last process.
#Get list of files from request_directory @request_files = <REQUESTS>; #start submitting jobs for the not_yet_run requests while (( $available_machine) && ($request_file_exists){ #this should be the parent process #read request file ($bling, $file, $Tool) = split(/~/, $request_file); open(REQ,"<$home/Input_Files/$request_file"); while (<REQ>){ $line = $_; #process each $line in the file to extract info that I #want } #Once I have extracted the information from the file #I want that to be the input to a child process #fork process to run SubmitToChi $child_id = fork; if ($child_id == 0){ #this is the child process #print STDERR "run $cmd on $request_file on $mach\n"; #run ChiSub using a remote shell (should I use #someth +ing else?) `rsh $mach $cmd $path $file $family $sub_family $seq_size $Tool`; + #these variables are my input to the child process } }
Please Monks, let me know what you think is the problem. I am not familiar with the fork process, so I don't know why the last child process is being repeated twice. Thanks

In reply to fork processes by arodri7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.