From 2f69ca37d3b38a3100408e9bdf5207a70cd1860c Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Thu, 9 Jan 2014 10:53:25 +0000 Subject: [PATCH] Better CGI error diagnostic for UNIX --- mongoose.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mongoose.c b/mongoose.c index d2abcce2..65e90198 100644 --- a/mongoose.c +++ b/mongoose.c @@ -712,6 +712,7 @@ static pid_t start_process(char *interp, const char *cmd, const char *env, #else static pid_t start_process(const char *interp, const char *cmd, const char *env, const char *envp[], const char *dir, sock_t sock) { + char buf[500]; pid_t pid = fork(); (void) env; @@ -732,6 +733,10 @@ static pid_t start_process(const char *interp, const char *cmd, const char *env, } else { execle(interp, interp, cmd, NULL, envp); } + snprintf(buf, sizeof(buf), "Status: 500\r\n\r\n" + "500 Server Error: %s%s%s: %s", interp == NULL ? "" : interp, + interp == NULL ? "" : " ", cmd, strerror(errno)); + send(1, buf, strlen(buf), 0); exit(EXIT_FAILURE); // exec call failed }