From 60f8cd4072ff244618f2c23dd12d6d8b2a5bf5f2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 15 May 2020 16:15:58 +0200 Subject: osdep: remove posix_spawn() helpers and wrappers See previous commit. Farewell, useless shitty POSIX function. --- osdep/android/posix-spawn.c | 72 --------------------------------------------- osdep/android/posix-spawn.h | 43 --------------------------- osdep/posix-spawn.h | 29 ------------------ osdep/subprocess.c | 2 +- wscript | 16 ---------- wscript_build.py | 3 +- 6 files changed, 2 insertions(+), 163 deletions(-) delete mode 100644 osdep/android/posix-spawn.c delete mode 100644 osdep/android/posix-spawn.h delete mode 100644 osdep/posix-spawn.h diff --git a/osdep/android/posix-spawn.c b/osdep/android/posix-spawn.c deleted file mode 100644 index a9bb27a8d1..0000000000 --- a/osdep/android/posix-spawn.c +++ /dev/null @@ -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 . - */ - -#include -#include -#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; -} diff --git a/osdep/android/posix-spawn.h b/osdep/android/posix-spawn.h deleted file mode 100644 index d995b993ec..0000000000 --- a/osdep/android/posix-spawn.h +++ /dev/null @@ -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 . - */ - -#pragma once - -#include - -#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 []); diff --git a/osdep/posix-spawn.h b/osdep/posix-spawn.h deleted file mode 100644 index fdba50149c..0000000000 --- a/osdep/posix-spawn.h +++ /dev/null @@ -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 . - */ - -#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 -#endif diff --git a/osdep/subprocess.c b/osdep/subprocess.c index 8a930a60df..4b5770bf5c 100644 --- a/osdep/subprocess.c +++ b/osdep/subprocess.c @@ -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, diff --git a/wscript b/wscript index d0a5833dd9..96fab9d5e6 100644 --- a/wscript +++ b/wscript @@ -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', diff --git a/wscript_build.py b/wscript_build.py index 93933e7371..a35d1039e5 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -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" ), -- cgit v1.2.3