Strange behaviour with perl and apache

Discussion in 'Perl' started by David Cantin, Nov 3, 2003.

  1. David Cantin

    David Cantin Guest

    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
     
    David Cantin, Nov 3, 2003
    #1
    1. Advertising

  2. David Cantin

    Jim Gibson Guest

    In article <>, David
    Cantin <> 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.
     
    Jim Gibson, Nov 3, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve D
    Replies:
    0
    Views:
    186
    Steve D
    Aug 26, 2003
  2. The Poor
    Replies:
    2
    Views:
    245
    Gregory Toomey
    Sep 27, 2003
  3. Nikita Synytskyy

    Strange printing behaviour of Perl programs

    Nikita Synytskyy, Jan 20, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    143
    Nikita Synytskyy
    Jan 20, 2004
  4. Replies:
    3
    Views:
    303
  5. Eric
    Replies:
    2
    Views:
    148
Loading...

Share This Page