Fix adb server hang
Since commit 0426708544
, the server is run
in a dedicated thread. For SDL, many signals, including SIGINT and
SIGTERM, are masked for new threads. As a result, if the adb server is
not already running, adb commands invoked by scrcpy will start an adb
server that ignores those signals and cannot be terminated at system
shutdown.
Fixes #2873 <https://github.com/Genymobile/scrcpy/issues/2873>
PR #2870 <https://github.com/Genymobile/scrcpy/pull/2870>
Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
parent
0685c491cd
commit
d049671908
1 changed files with 7 additions and 0 deletions
|
@ -119,6 +119,13 @@ sc_process_execute_p(const char *const argv[], sc_pid *pid, unsigned flags,
|
||||||
|
|
||||||
close(internal[0]);
|
close(internal[0]);
|
||||||
enum sc_process_result err;
|
enum sc_process_result err;
|
||||||
|
|
||||||
|
// Somehow SDL masks many signals - undo them for other processes
|
||||||
|
// https://github.com/libsdl-org/SDL/blob/release-2.0.18/src/thread/pthread/SDL_systhread.c#L167
|
||||||
|
sigset_t mask;
|
||||||
|
sigemptyset(&mask);
|
||||||
|
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||||
|
|
||||||
if (fcntl(internal[1], F_SETFD, FD_CLOEXEC) == 0) {
|
if (fcntl(internal[1], F_SETFD, FD_CLOEXEC) == 0) {
|
||||||
execvp(argv[0], (char *const *) argv);
|
execvp(argv[0], (char *const *) argv);
|
||||||
perror("exec");
|
perror("exec");
|
||||||
|
|
Loading…
Reference in a new issue