Romain Vimont
ba547e3895
Configure feature test macros in meson
...
Refs #2807 <https://github.com/Genymobile/scrcpy/pull/2807 >
Co-authored-by: RipleyTom <RipleyTom@users.noreply.github.com>
4 years ago
Romain Vimont
9cb14b5166
Inherit only specific handles on Windows
...
To be able to communicate with a child process via stdin, stdout and
stderr, the CreateProcess() parameter bInheritHandles must be set to
TRUE. But this causes *all* handles to be inherited, including sockets.
As a result, the server socket was inherited by the process running adb
to execute the server on the device, so it could not be closed properly,
causing other scrcpy instances to fail.
To fix the issue, use an extended API to explicitly set the HANDLEs to
inherit:
- <https://stackoverflow.com/a/28185363/1987178 >
- <https://devblogs.microsoft.com/oldnewthing/20111216-00/?p=8873 >
Fixes #2779 <https://github.com/Genymobile/scrcpy/issues/2779 >
PR #2783 <https://github.com/Genymobile/scrcpy/pull/2783 >
4 years ago
Romain Vimont
9cb8766220
Factorize resource release after CreateProcess()
...
Free the wide characters string in all cases before checking for errors.
4 years ago
Romain Vimont
fd4ec784e0
Remove useless assignments on error
...
Leave the output parameter untouched on error.
4 years ago
Romain Vimont
52cebe1597
Fix Windows sc_pipe function names
...
The implementation name was incorrect (it was harmless, because they are
not used on Windows).
4 years ago
Romain Vimont
057c7a4df4
Move str_util to str
...
Simplify naming.
4 years ago
Romain Vimont
979ce64dc0
Improve string util API
...
Use prefixed names and improve documentation.
4 years ago
Romain Vimont
aa011832c1
Improve process API
...
Prefix symbols and constants names and improve documentation.
4 years ago
Romain Vimont
7e93abcf6d
Factorize common impl of process_execute()
...
Both implementations are the same. Move them to the common process.c.
4 years ago
Romain Vimont
d4c262301f
Move functions from process to file
...
Move filesystem-related functions from process.[ch] to file.[ch].
4 years ago
Romain Vimont
eaf4afaad9
Add command execution with redirection
...
Expose command execution with pipes to stdin, stdout and stderr.
This will allow to read the result of adb commands.
4 years ago
Wirtos_new
a9d9cbf8b5
Replace VLA by dynamic allocation
...
And increase the command buffer size.
Refs #1358 <https://github.com/Genymobile/scrcpy/issues/1358#issuecomment-862989748 >
PR #2405 <https://github.com/Genymobile/scrcpy/pull/2405 >
Signed-off-by: Romain Vimont <rom@rom1v.com>
5 years ago
Romain Vimont
710e80aa0d
Return build_cmd() success via a boolean
...
For consistency with other functions in the codebase.
5 years ago
Romain Vimont
30e619d37f
Replace SDL_strdup() by strdup()
...
The functions SDL_malloc(), SDL_free() and SDL_strdup() were used only
because strdup() was not available everywhere.
Now that it is available, use the native version of these functions.
5 years ago
Romain Vimont
6a50231698
Expose a single process_wait()
...
There were two versions: process_wait() and process_wait_noclose().
Expose a single version with a flag (it was already implemented that way
internally).
5 years ago
Romain Vimont
b8edcf52b0
Simplify process_wait()
...
The function process_wait() returned a bool (true if the process
terminated successfully) and provided the exit code via an output
parameter exit_code.
But the returned value was always equivalent to exit_code == 0, so just
return the exit code instead.
5 years ago
Romain Vimont
59feb2a15c
Group common includes into common.h
...
Include config.h and compat.h in common.h, and include common.h from all
source files.
5 years ago
Romain Vimont
d580ee30f1
Separate process wait and close
...
On Linux, waitpid() both waits for the process to terminate and reaps it
(closes its handle). On Windows, these actions are separated into
WaitForSingleObject() and CloseHandle().
Expose these actions separately, so that it is possible to send a signal
to a process while waiting for its termination without race condition.
This allows to wait for server termination normally, but kill the
process without race condition if it is not terminated after some delay.
5 years ago
Romain Vimont
821c175730
Rename process_simple_wait to process_wait
...
Adding "simple" in the function name brings no benefit.
5 years ago
Romain Vimont
4bd9da4c93
Split command into process and adb
...
The process API provides the system-specific implementation, the adb API
uses it to expose adb commands.
5 years ago