Hi all,

I've tried the following code:

#!/perl/bin/perl -w

use strict;

$| = 1;

print "Content-type: text/html\n\n";

my $pid=fork;

if ($pid) {
print "parent<br>\n";
exit 0;
}
else {
&sub;
}

sub sub {
sleep(100);
open(OUT, ">>f:/teddy/zzzz.txt") or die "Can't write to zzzz.txt - $!";
print OUT "test";
close OUT;
}


This script should fork the child process which after waiting 100 seconds it
should print a test text in a file.
The problem is that if I run the script from a web browser it waits for 100
seconds before it finishes.

If I add:

close STDOUT; close STDIN; close STDERR;

...The script ends immediately, but the child process is not executed at
all.

I am trying to make it work under Windows and Linux.

Help!

I've discovered that I can make what I want if I create 3 scripts.
1. Just exec the second perl script with exec("perl script2.pl");

2. Forks a child process and in the child process exec() the third perl
script.
3. Just does what I want (the time consuming script).

Is there a method to do this without needing 3 scripts?
I would like to do it with only  1 ...or 2.


Thank you.

Teddy,
teddy.fcc.ro     [EMAIL PROTECTED]


-------------------------------------------------------
Xnet scaneaza automat toate mesajele impotriva virusilor folosind RAV AntiVirus.
Xnet automatically scans all messages for viruses using RAV AntiVirus.

Nota: RAV AntiVirus poate sa nu detecteze toti virusii noi sau toate variantele lor.
Va rugam sa luati in considerare ca exista un risc de fiecare data cand deschideti
fisiere atasate si ca MobiFon nu este responsabila pentru nici un prejudiciu cauzat
de virusi.

Disclaimer: RAV AntiVirus may not be able to detect all new viruses and variants.
Please be aware that there is a risk involved whenever opening e-mail attachments
to your computer and that MobiFon is not responsible for any damages caused by
viruses.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to