I am trying to use fork to perform a rather long task. The problem I'm having is that the child process doesn't seem to be able to access files. At least I think that's the problem. I fork using this code. It's not mine, I just grabbed it from somewhere... (die statements shortened for clarity...)
$SIG{CHLD} = 'IGNORE'; defined (my $kid = fork) or die "Cannot fork: $!\n"; if($kid) { # do nothing... } else { chdir '/webRoot/cgi-bin' or die ... open STDIN, '/dev/null' or die ... open STDOUT, '>/dev/null' or die ... open STDERR, '>/tmp/log' or die ... setsid or die ... my $oldfh = select STDERR; local $| = 1; select $oldfh; my $run = "perl /webRoot/apps/startPipe.pl -f $dest_file -j $job_ ++ID -c $created -t $job_type $adv_opts"; `$run`; CORE::exit(0); # terminate the process }
Then in the file startPipe.pl...
for my $i (1 .. 1) { $arab_string .= "my \@arab$i = ("; $blast_run = "blastn ATH1_chr$i.1con.01222004 $seq_file_name - +wa +rnings"; warn "$blast_run\n"; $blast_output = `$blast_run`; warn "Error: $!\n"; ...
and finally in the file /tmp/log
blastn ATH1_chr1.1con.01222004 /webRoot/cgi-bin/jobs/15-12-2007/WZuFQe + +miR8sSigXB3vFjLiuix/WZuFQemiR8sSigXB3vFjLiuix -warnings Error: No such file or directory
and if i copy the the string generated by $blast_run and paste it into bash it will work, the files are in the right places. I have chmodded everything to 777 to make sure that it's not permissions. I'm probably missing something very simple... Thanks.

In reply to File Access for child process by crunchi

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.