How to make a cgi program "die" without a software error messagebeing printed to page

Discussion in 'Perl Misc' started by gsa, Jan 28, 2010.

  1. gsa

    gsa Guest

    Hi all,
    I have this cgi code that sometimes forks depending on the
    size of input. If there is an error, a subroutine called print_error
    is called and this subroutine prints an error message and dies. If the
    cgi forks and there is a child, then this error message is captured by
    an eval statement and is printed to the log file. However, if the cgi
    does not fork, there is an ugly software error message on the page. Is
    there a way to die so that when the cgi forks, eval captures the error
    message but at the same time there is no nasty software error when the
    cgi doesn't fork? I guess the easiest way is to turn CGI::Carp off but
    is there another way to exit/die?

    Thanks a lot!
    Gayathri
     
    gsa, Jan 28, 2010
    #1
    1. Advertising

  2. gsa

    Bart Lateur Guest

    Re: How to make a cgi program "die" without a software error message being printed to page

    gsa wrote:

    > I have this cgi code that sometimes forks depending on the
    >size of input. If there is an error, a subroutine called print_error
    >is called and this subroutine prints an error message and dies. If the
    >cgi forks and there is a child, then this error message is captured by
    >an eval statement and is printed to the log file. However, if the cgi
    >does not fork, there is an ugly software error message on the page. Is
    >there a way to die so that when the cgi forks, eval captures the error
    >message but at the same time there is no nasty software error when the
    >cgi doesn't fork?


    fork returns a child process id if it forks, so you can know if you're
    in the parent or in the child. Store it in a variable. Simply let the
    error handler behave differently depending on what's in that variable.

    You may want to use a dummy value in that variable in case you skip
    forking, and thus, you actually are in the parent.

    --
    Bart.
     
    Bart Lateur, Jan 29, 2010
    #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. Lloyd Sheen

    Die IDE Die

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    436
    Natty Gur
    Jan 26, 2004
  2. Lloyd Sheen

    More Die IDE Die

    Lloyd Sheen, Jan 24, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    453
    Alvin Bruney
    Jan 25, 2004
  3. Jack Saalweachter

    God, software patents, I hate you, die.

    Jack Saalweachter, Oct 25, 2005, in forum: C++
    Replies:
    1
    Views:
    294
    Jack Saalweachter
    Oct 25, 2005
  4. Perl Learner
    Replies:
    1
    Views:
    200
    Jim Keenan
    Jun 13, 2005
  5. bernd

    CGI::Carp die with status

    bernd, Feb 5, 2008, in forum: Perl Misc
    Replies:
    6
    Views:
    176
Loading...

Share This Page