Re: How to simple exit in CGI?
Jean Louis <[email protected]> Wed, 29 Mar 2017 10:51:12 +0300
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Mar 29, 2017 at 02:15:04AM +0200, Pascal Bourguignon wrote:
> > *** - Ctrl-C: User break
> > Break 1 [1]>
>
> Well, it looks like test.cgi was hung, not printing anything, and
> that your web server decided to kill it with a SIGINT. This was
> interpreted as a C-c by clisp, and entered into the debugger, then
> the web server took that output and returned it.
Yes, that is what I assume.
> Here’s how I catch and report errors, saving them into files:
>
> I’ve left the call to (error "Simulated error.”) for your tests.
> You must remove it (and recompile with make) before trying it for real.
>
> In this case, we want to catch the errors before issuing the
> headers, so I collect them into a string errout, and then depending
> on whether there was an error to compute query, I print an error web
> page, or perform the normal processing.
Thank you much.
Good to know, I will be using it now.
> <1/89> #<system-function show-stack> 3
> <2/82> #<compiled-function system::print-backtrace>
> <3/78> #<compiled-function jean-cgi::print-backtrace>
> [64] frame binding variables (~ = dynamically):
> | ~ *print-level* <--> nil
> Printed 3 frames
> ERROR while ((setf jean-cgi::query (or (error "Simulated error.") (getenv "QUERY_STRING") (alexandria.0.dev:read-stream-content-into-string *standard-input*)))):
> Simulated error.
>
> [pjb@despina :0.0 jean]$
>
> Works nicely, the error is detected and reported.
> After having removed the call to error, it works as expected:
>
> [pjb@despina :0.0 jean]$ sudo rm /tmp/jean-cgi.*
> Password:
> [pjb@despina :0.0 jean]$ ./jean.cgi </dev/null
> Status: 302 Found
> Location: http://localhost
>
>
> Got query: ""
> at url: "http://localhost”
So it works for you?
I have tried now with 3-4 web servers.
If I let this like following:
(let ((errout (with-output-to-string (*error-output*)
(reporting-errors
(setf query (or (getenv "QUERY_STRING")
(alexandria:read-stream-content-into-string *standard-input*)))))))
I do not wait this time long, maybe 3-4 seconds, then I get:
wget -O /dev/shm/test "http://localhost/test.cgi"; less /dev/shm/test
--2017-03-29 10:46:46-- http://localhost/test.cgi
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2017-03-29 10:46:53 ERROR 500: Internal Server Error.
and /tmp/jean-cgi.trace is empty, no other file.
What is wrong on my side that is different to your side? It works on
your side, and not on my side.
Jean
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list