vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sat Sep 19 12:53:29 2020 +0300| [03390c7f346e5e6911461d443095e4523884fe1b] | committer: Rémi Denis-Courmont
proxy: use vlc_spawn() > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=03390c7f346e5e6911461d443095e4523884fe1b --- src/posix/netconf.c | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/posix/netconf.c b/src/posix/netconf.c index e2db67b386..4ec82612d9 100644 --- a/src/posix/netconf.c +++ b/src/posix/netconf.c @@ -24,19 +24,11 @@ #include <stdlib.h> #include <string.h> -#include <signal.h> - -#include <sys/types.h> -#include <sys/wait.h> -#include <fcntl.h> -#include <spawn.h> -#include <unistd.h> - -extern char **environ; #include <vlc_common.h> #include <vlc_fs.h> #include <vlc_network.h> +#include <vlc_spawn.h> /** * Determines the network proxy server to use (if any). @@ -45,43 +37,18 @@ extern char **environ; */ char *vlc_getProxyUrl(const char *url) { - /* libproxy helper */ - pid_t pid; - posix_spawn_file_actions_t actions; - posix_spawnattr_t attr; - char *argv[3] = { (char *)"proxy", (char *)url, NULL }; int fd[2]; if (vlc_pipe(fd)) return NULL; - if (posix_spawn_file_actions_init(&actions)) - return NULL; - if (posix_spawn_file_actions_addopen(&actions, STDIN_FILENO, "/dev/null", - O_RDONLY, 0644) || - posix_spawn_file_actions_adddup2(&actions, fd[1], STDOUT_FILENO)) - { - posix_spawn_file_actions_destroy(&actions); - return NULL; - } - - posix_spawnattr_init(&attr); - { - sigset_t set; - - sigemptyset(&set); - posix_spawnattr_setsigmask(&attr, &set); - sigaddset (&set, SIGPIPE); - posix_spawnattr_setsigdefault(&attr, &set); - posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF - | POSIX_SPAWN_SETSIGMASK); - } + pid_t pid; + int fdv[] = { -1, fd[1], STDERR_FILENO, -1 }; + const char *argv[] = { "proxy", url, NULL }; - if (posix_spawnp(&pid, "proxy", &actions, &attr, argv, environ)) + if (vlc_spawnp(&pid, "proxy", fdv, argv)) pid = -1; - posix_spawnattr_destroy(&attr); - posix_spawn_file_actions_destroy(&actions); vlc_close(fd[1]); if (pid != -1) @@ -99,7 +66,7 @@ char *vlc_getProxyUrl(const char *url) while (len < sizeof (buf)); vlc_close(fd[0]); - while (waitpid(pid, &(int){ 0 }, 0) == -1); + vlc_waitpid(pid); if (len >= 9 && !strncasecmp(buf, "direct://", 9)) return NULL; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
