1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-23 23:32:26 +00:00

osdep: remove posix_spawn() helpers and wrappers

See previous commit. Farewell, useless shitty POSIX function.
This commit is contained in:
wm4 2020-05-15 16:15:58 +02:00
parent 5309497727
commit 60f8cd4072
6 changed files with 2 additions and 163 deletions

View File

@ -1,72 +0,0 @@
/*
* posix-spawn replacement for Android
*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#include <unistd.h>
#include <errno.h>
#include "osdep/android/posix-spawn.h"
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, int fd, int newfd)
{
if (fa->used >= MAX_FILE_ACTIONS)
return -1;
fa->action[fa->used].filedes = fd;
fa->action[fa->used].newfiledes = newfd;
fa->used++;
return 0;
}
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *fa)
{
fa->used = 0;
return 0;
}
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *fa)
{
return 0;
}
int posix_spawnp(pid_t *pid, const char *file,
const posix_spawn_file_actions_t *fa,
const posix_spawnattr_t *attrp,
char *const argv[], char *const envp[])
{
pid_t p;
if (attrp != NULL)
return EINVAL;
p = fork();
if (p == -1)
return errno;
if (p == 0) {
for (int i = 0; i < fa->used; i++) {
int err = dup2(fa->action[i].filedes, fa->action[i].newfiledes);
if (err == -1)
goto fail;
}
execvpe(file, argv, envp);
fail:
_exit(127);
}
*pid = p;
return 0;
}

View File

@ -1,43 +0,0 @@
/*
* posix-spawn replacement for Android
*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <sys/types.h>
#define MAX_FILE_ACTIONS 4
typedef struct {
char dummy;
} posix_spawnattr_t; /* unsupported */
typedef struct {
int used;
struct {
int filedes, newfiledes;
} action[MAX_FILE_ACTIONS];
} posix_spawn_file_actions_t;
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t*, int, int);
int posix_spawn_file_actions_init(posix_spawn_file_actions_t*);
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t*);
int posix_spawnp(pid_t*, const char*,
const posix_spawn_file_actions_t*, const posix_spawnattr_t *,
char *const [], char *const []);

View File

@ -1,29 +0,0 @@
/*
* posix-spawn wrapper
*
* This file is part of mpv.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "config.h"
#if HAVE_ANDROID
// posix_spawn(p) does not exist at all on Android
#include "osdep/android/posix-spawn.h"
#else
#include <spawn.h>
#endif

View File

@ -29,7 +29,7 @@ void mp_devnull(void *ctx, char *data, size_t size)
{
}
#if HAVE_POSIX_SPAWN
#if HAVE_POSIX
int mp_subprocess(char **args, struct mp_cancel *cancel, void *ctx,
subprocess_read_cb on_stdout, subprocess_read_cb on_stderr,

16
wscript
View File

@ -241,22 +241,6 @@ iconv support use --disable-iconv.",
'desc': 'w32/dos paths',
'deps': 'os-win32 || os-cygwin',
'func': check_true
}, {
'name': 'posix-spawn-native',
'desc': 'spawnp()/kill() POSIX support',
'func': check_statement(['spawn.h', 'signal.h'],
'posix_spawnp(0,0,0,0,0,0); kill(0,0)'),
'deps': '!mingw && !tvos',
}, {
'name': 'posix-spawn-android',
'desc': 'spawnp()/kill() Android replacement',
'func': check_true,
'deps': 'android && !posix-spawn-native',
},{
'name': 'posix-spawn',
'desc': 'any spawnp()/kill() support',
'deps': 'posix-spawn-native || posix-spawn-android',
'func': check_true,
}, {
'name': 'glob-posix',
'desc': 'glob() POSIX support',

View File

@ -222,7 +222,7 @@ def build(ctx):
])
subprocess_c = ctx.pick_first_matching_dep([
( "osdep/subprocess-posix.c", "posix-spawn" ),
( "osdep/subprocess-posix.c", "posix" ),
( "osdep/subprocess-win.c", "win32-desktop" ),
( "osdep/subprocess-dummy.c" ),
])
@ -545,7 +545,6 @@ def build(ctx):
( timer_c ),
( "osdep/polldev.c", "posix" ),
( "osdep/android/posix-spawn.c", "android"),
( "osdep/android/strnlen.c", "android"),
( "osdep/glob-win.c", "glob-win32" ),
( "osdep/macosx_application.m", "cocoa" ),