Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Strange behaviour with perl and apache

Reply
Thread Tools

Strange behaviour with perl and apache

 
 
David Cantin
Guest
Posts: n/a
 
      11-03-2003
Hi

I have some troubles with a long system() sub-process (from 30 sec to
30 min) called from a CGI.

My web page have to wait the end of the system() call before finishing
it's loadding but this is not whats appen. The web page is waiting for
a couple of minutes but continue and finish it's loadding before the
end of program called by the system() call

Here a part of my "pseudo" code :

^- other code (html stuff)...

if (!is_lock($file_name, $file_date)){
lock($file_name, $file_date)
system "path_to_long_execution_prog $file_name $file_date";
my $exit_value = wait();
unlock($file_name, $file_date)
} else {
log("Error :: Trying to redo the system call ?!?");
}

and yes, I got "Error :: Trying to redo the system call ?!?" in my log
and is not suppose to... and I don't know why !

I run on a AIX server whith apache 1.3.27 and perl 5.005_02

Dave
 
Reply With Quote
 
 
 
 
Jim Gibson
Guest
Posts: n/a
 
      11-03-2003
In article <(E-Mail Removed)> , David
Cantin <(E-Mail Removed)> wrote:

> Hi
>
> I have some troubles with a long system() sub-process (from 30 sec to
> 30 min) called from a CGI.
>
> My web page have to wait the end of the system() call before finishing
> it's loadding but this is not whats appen. The web page is waiting for
> a couple of minutes but continue and finish it's loadding before the
> end of program called by the system() call


You don't need to do a wait() after a call to system(). The system()
call does a fork, an exec, and a wait in the parent process to wait for
the child process before returning to your main program. You should
also check the return from system() to see if an error occurred (see
below).
>
> Here a part of my "pseudo" code :


It is better to post real code. Write a short perl program that calls
the same program and see what happens when you execute the perl program
from the command line (you may have to supply some things normally
supplied by your web server). Then post the program and the results if
you still get an error you can't diagnose.

>
> ^- other code (html stuff)...
>
> if (!is_lock($file_name, $file_date)){
> lock($file_name, $file_date)
> system "path_to_long_execution_prog $file_name $file_date";


Replace above line with:

system "path..." == 0 or die "system failed: $?";

> my $exit_value = wait();

Delete the above line.

> unlock($file_name, $file_date)
> } else {
> log("Error :: Trying to redo the system call ?!?");
> }
>
> and yes, I got "Error :: Trying to redo the system call ?!?" in my log
> and is not suppose to... and I don't know why !
>
> I run on a AIX server whith apache 1.3.27 and perl 5.005_02
>
> Dave


FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
for better responses.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Perl - strange behaviour with backticks Eric Perl Misc 2 09-13-2007 10:02 PM
Apache+Perl Net::SMTP Strange problem zhaoningli@gmail.com Perl Misc 3 05-18-2007 03:38 AM
Strange printing behaviour of Perl programs Nikita Synytskyy Perl Misc 6 01-20-2004 09:31 PM
How to test speed difference of Perl/Apache and SSI/Apache The Poor Perl Misc 2 09-27-2003 12:26 PM
Strange behaviour with "do" and Perl 5.8 Steve D Perl Misc 0 08-26-2003 10:30 PM



Advertisments