From f1e9daa7465d820de1cd25b916e5ae2e87e11658 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 2 Apr 2020 01:10:00 +0200 Subject: [PATCH] bpo-40094: CGIHTTPRequestHandler logs exit code CGIHTTPRequestHandler of http.server now logs the CGI script exit code, rather than the CGI script exit status of os.waitpid(). For example, if the script is killed by signal 11, it now logs: "CGI script exit code -11." --- Lib/http/server.py | 5 +++-- .../next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst diff --git a/Lib/http/server.py b/Lib/http/server.py index 2d74b95586cff4..fa204fbc15e3d7 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -1164,8 +1164,9 @@ def run_cgi(self): while select.select([self.rfile], [], [], 0)[0]: if not self.rfile.read(1): break - if sts: - self.log_error("CGI script exit status %#x", sts) + exitcode = os.waitstatus_to_exitcode(sts) + if exitcode: + self.log_error(f"CGI script exit code {exitcode}") return # Child try: diff --git a/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst b/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst new file mode 100644 index 00000000000000..ba13d3cdf4a8db --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-04-02-01-13-28.bpo-40094.AeZ34K.rst @@ -0,0 +1,3 @@ +CGIHTTPRequestHandler of http.server now logs the CGI script exit code, +rather than the CGI script exit status of os.waitpid(). For example, if the +script is killed by signal 11, it now logs: "CGI script exit code -11."