aboutsummaryrefslogtreecommitdiff
path: root/win32/popen.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: consolidate executable handling in popen.cRon Yorston2024-07-201-31/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | Commit f444dc586 (win32: only search PATH for compressor) made mingw_fork_compressor() perform a PATH lookup for the xz and lzma compression programs. This avoided relying on CreateProcess() to perform the search. Other callers of the pipe creation code should also avoid reliance on CreateProcess's executable search: - Move the applet test and PATH lookup into mingw_popen_internal(). The first argument to CreateProcess() will always be a path to an executable. - mingw_fork_compressor() uses the new "w+" mode to indicate that xz and lzma compressors should be found on PATH. - mingw_popen() no longer needs to check for an applet itself, as that's now handled in mingw_popen_internal(). - spawn_ssl_client() in 'wget' can rely on the popen code to look up the 'ssl_client' applet. - Remove unnecessary argument checks in mingw_popen_internal(). Adds 0-24 bytes.
* win32: code shrink popen(3)Ron Yorston2024-07-191-40/+13
| | | | | | | | | | | - Replace the half-baked code to quote the command passed to popen(3) with a call to quote_arg(). - Where the command to be run is a non-overridden applet in the current binary pass the path to the binary to CreateProcess() instead of adding '--busybox' to the command. Saves 128-136 bytes.
* win32: only search PATH for compressorRon Yorston2023-11-141-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | mingw_fork_compressor() uses CreateProcess() to run the compressor program. This will often be an instance of BusyBox, but since the xv and lzma applets in BusyBox don't support compression it can be an external program. It was intended that the external program should be found using PATH. However, CreateProcess() looks in various other places before trying PATH. In particular, it first looks in the directory of the current executable, then in the current directory of the process. This can result in the wrong xz.exe or lzma.exe being found. Perform an explicit PATH search and force CreateProcess() to use the result. This change only affects the search for a compressor. The same problem also affects other uses of our popen(3) emulation. These may be addressed in future. Costs 64-80 bytes. (GitHub issue #376)
* win32: proper conditional compilation in popen.cRon Yorston2022-04-231-9/+14
| | | | | | | | | | | In mingw_fork_compressor() the code to prefer applets over external programs should be conditionally compiled based on the setting of ENABLE_FEATURE_PREFER_APPLETS. In mingw_popen() there's no need to use ENABLE_FEATURE_SH_STANDALONE for the same purpose. ENABLE_FEATURE_PREFER_APPLETS is sufficient. Save a few bytes by sharing a format string in mingw_fork_compressor().
* tar: use external program for lzma/xz compressionRon Yorston2021-07-221-3/+9
| | | | | | | | | The lzma and xz applets don't support compression. Any attempt to generate a tar file using these compressors should try to use an external program. (Which probably won't work on a typical Windows system, but hey, at least we made the effort.) See GitHub issue #222.
* win32: move code to fork (de)compressor to a functionRon Yorston2020-08-051-0/+22
| | | | | | | | Use a new common function, mingw_fork_compressor(), to implement fork_transformer() in open_transformer.c and vfork_compressor() in tar.c. Saves 160 bytes.
* win32: don't leak pipe data structuresRon Yorston2018-04-071-58/+66
| | | | | | | | | | | | popen uses an array of pipe_data structures to record information that's later used by pclose. pclose releases the structure after use. The lower-level pipe function mingw_popen_fd was also using this array of structures but didn't provide any way to release them. Avoid this leak by letting mingw_popen_fd use a local structure instead.
* win32: tidy up popen implementationRon Yorston2018-03-151-206/+75
| | | | | | | | | Make mingw_popen_fd sufficiently general that it can be used to implement the other two popen routines. mingw_popen now just creates a command line and passes it to mingw_popen_fd. The one call to mingw_popen2 has been replaced by a call to mingw_popen_fd.
* wget: add support for httpsRon Yorston2018-03-151-0/+103
| | | | | | | | | | | | | | | | Allow wget to support https URLs. Changes are: - Add mingw_popen2 which uses a named pipe to allow bidirectional communication with a child process; - Modify ssl_client to accept a WIN32 handle instead of a file descriptor as an argument; - Allow tls_get_random to open /dev/urandom; - Using the above changes implement a WIN32 version of spawn_ssl_client in wget. This closes GitHub issue #75. Also, enable authentication in wget.
* win32: use built-in shell for popen, if possibleRon Yorston2018-02-181-2/+12
| | | | | | | | | | | | | | | popen uses the shell to run the command provided. If BusyBox has been configured appropriately use the built-in shell for this. - Currently the only user of popen in busybox-w32 is awk, which uses it when piping to or from commands. - If the command is available as an applet the shell will use it. If a different version of the program is required the command will need to specify the full path. - This change means that popen will work even if no shell is present on the path. - Since the binary may have been run as sh.exe or awk.exe it's necessary to use the magic --busybox option.
* win32: correct cast of argument to _open_osfhandleRon Yorston2016-05-251-4/+4
|
* mingw: add routine to pipe a file descriptor to/from a commandRon Yorston2015-05-271-18/+128
|
* Tidy up mingw_popenRon Yorston2014-05-151-59/+47
| | | | This also fixes piping output to a command in awk.
* win32: add popen implementation that uses shellRon Yorston2012-04-231-0/+220