Skip to content

close unused file descriptors#5

Open
sgerwk wants to merge 1 commit intoklange:masterfrom
sgerwk:master
Open

close unused file descriptors#5
sgerwk wants to merge 1 commit intoklange:masterfrom
sgerwk:master

Conversation

@sgerwk
Copy link
Copy Markdown

@sgerwk sgerwk commented Jan 16, 2021

Without this, a cgi reading from stdin will block because it still has the
write end of the pipe open. This matters to cgi scripts using POST requests
with multipart/form-data, as the examples in pages/index.cgi and
pages/getfile.cgi (let me know if you want me to remove these two files from
the commit, they are just examples to demonstrate the problem).

Without this, a cgi reading from stdin will block because it still has the
write end of the pipe open. This matters to cgi scripts using POST requests
with multipart/form-data, as the examples in pages/index.cgi and
pages/getfile.cgi (let me know if you want me to remove these two files from
the commit, they are just examples to demonstrate the problem).
@gereoffy
Copy link
Copy Markdown

thank you, it saved my life :)

@gereoffy
Copy link
Copy Markdown

gereoffy commented Jan 29, 2025

2 more close were missing in the fork-parent process:

@@ -936,6 +936,8 @@
 					 * cgi_pipe_post is mapped to the stdin for the CGI application
 					 * and we pipe our POST data (if there is any) here.
 					 */
+					close(cgi_pipe_w[1]);
+					close(cgi_pipe_r[0]);
 					FILE * cgi_pipe = fdopen(cgi_pipe_w[0], "r");
 					FILE * cgi_pipe_post = fdopen(cgi_pipe_r[1], "w");

and the _waitthread mess is no longer required!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants