diff options
author | Ron Yorston <rmy@pobox.com> | 2023-12-20 13:45:32 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-12-20 13:59:17 +0000 |
commit | 8d85a4a5be88931978fad594b94e762313d37afc (patch) | |
tree | 0f964f6cd9b0c71b02de5011a2f815e1470c8740 /include | |
parent | 4f9b703c31e6360d1e7ffe7d3410e42e5118b4fd (diff) | |
download | busybox-w32-8d85a4a5be88931978fad594b94e762313d37afc.tar.gz busybox-w32-8d85a4a5be88931978fad594b94e762313d37afc.tar.bz2 busybox-w32-8d85a4a5be88931978fad594b94e762313d37afc.zip |
httpd: enable support for CGI
The upstream code uses fork/exec when running a CGI process.
Emulate this by:
- Spawning a child httpd process with the special '-I 0' option,
along with the options provided on the server command line. This
sets up the proper state then calls the cgi_handler() function.
- The cgi_handler() function fixes the pipe file descriptors and
starts another child process to run the CGI script.
These processes are detached from the console on creation. When
spawn() functions are run in P_DETACH mode they don't connect to
the standard file descriptors. Normally this doesn't matter but
the process which runs the CGI scripts needs to inherit the pipe
endpoints. The create_detached_process() function handles this.
See:
https://github.com/rprichard/win32-console-docs/blob/master/README.md
Adds about 2.9Kb to the size of the binary.
(GitHub issue #266)
Diffstat (limited to 'include')
-rw-r--r-- | include/mingw.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h index 46cbe03f8..88da85243 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -552,12 +552,14 @@ pid_t FAST_FUNC mingw_spawn(char **argv); | |||
552 | intptr_t FAST_FUNC mingw_spawn_detach(char **argv); | 552 | intptr_t FAST_FUNC mingw_spawn_detach(char **argv); |
553 | intptr_t FAST_FUNC mingw_spawn_proc(const char **argv); | 553 | intptr_t FAST_FUNC mingw_spawn_proc(const char **argv); |
554 | int mingw_execv(const char *cmd, char *const *argv); | 554 | int mingw_execv(const char *cmd, char *const *argv); |
555 | int httpd_execv_detach(const char *cmd, char *const *argv); | ||
555 | int mingw_execvp(const char *cmd, char *const *argv); | 556 | int mingw_execvp(const char *cmd, char *const *argv); |
556 | int mingw_execve(const char *cmd, char *const *argv, char *const *envp); | 557 | int mingw_execve(const char *cmd, char *const *argv, char *const *envp); |
557 | #define spawn mingw_spawn | 558 | #define spawn mingw_spawn |
558 | #define execvp mingw_execvp | 559 | #define execvp mingw_execvp |
559 | #define execve mingw_execve | 560 | #define execve mingw_execve |
560 | #define execv mingw_execv | 561 | #define execv mingw_execv |
562 | #define HTTPD_DETACH (8) | ||
561 | 563 | ||
562 | #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':') | 564 | #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':') |
563 | 565 | ||