Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to make a cgi program "die" without a software error messagebeing printed to page

Reply
Thread Tools

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

 
 
gsa
Guest
Posts: n/a
 
      01-28-2010
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
 
Reply With Quote
 
 
 
 
Bart Lateur
Guest
Posts: n/a
 
      01-29-2010
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.
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to make to transmit the parameters of a cgi between these various pages I would like to use param but I do not see how to make john.swilting Perl Misc 1 03-27-2007 09:46 AM
Calling another cgi program using CGI.pm dmedhora@gmail.com Perl Misc 12 08-28-2006 01:00 AM
Does bicubic resampling make a noticeable improvement to printed photos? Lee Digital Photography 35 06-12-2006 09:50 PM
How to make the program connect to next IP address without exiting program, if the current connection fail?? Abby C Programming 1 08-29-2003 03:08 AM



Advertisments