+ Moved http-error from the forked process into the server process.

+ Set stdin and stdout to the current-in/output-port after forking.
This commit is contained in:
mainzelm 2001-10-24 11:02:46 +00:00
parent 612ca1e0ad
commit aa2f04195e
1 changed files with 9 additions and 5 deletions

View File

@ -106,10 +106,9 @@
(env (cgi-env req bin-dir (cdr path))) (env (cgi-env req bin-dir (cdr path)))
(doit (lambda () (doit (lambda ()
(apply exec/env filename env argv) (dup->inport (current-input-port) 0)
(http-error http-reply/bad-request req (dup->outport (current-output-port) 1)
(format #f "Could not execute CGI script ~a." (apply exec/env filename env argv))))
filename)))))
(http-log "search: ~s, argv: ~s~%" search argv) (http-log "search: ~s, argv: ~s~%" search argv)
(let ((request-method (request:method req))) (let ((request-method (request:method req)))
@ -117,7 +116,12 @@
((or (string=? request-method "GET") ((or (string=? request-method "GET")
(string=? request-method "POST")) ; Could do others also. (string=? request-method "POST")) ; Could do others also.
(if nph? (if nph?
(wait (fork doit)) (let ((stat (wait (fork doit))))
(if (not (zero? stat))
(http-error http-reply/bad-request req
(format #f "Could not execute CGI script ~a."
filename))
stat))
(cgi-send-reply (run/port* doit) req))) (cgi-send-reply (run/port* doit) req)))
(else (http-error http-reply/method-not-allowed req))))) (else (http-error http-reply/method-not-allowed req)))))