Log stderr from CGI processes which exit with non-zero status to the error log. Closes #7.

This commit is contained in:
Solderpunk 2020-07-06 16:13:56 +02:00
parent b9334e07a9
commit 7d8bacdc90
1 changed files with 4 additions and 1 deletions

View File

@ -64,7 +64,10 @@ func handleCGI(config Config, path string, cgiPath string, URL *url.URL, log *Lo
return
}
if err != nil {
errorLog.Println("Error starting CGI executable " + path + ": " + err.Error())
errorLog.Println("Error running CGI program " + path + ": " + err.Error())
if err, ok := err.(*exec.ExitError); ok {
errorLog.Println("↳ stderr output: " + string(err.Stderr))
}
conn.Write([]byte("42 CGI error!\r\n"))
log.Status = 42
return