X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fextras%2Flibc.c;h=1be7fe81c84a4d3c2490142d4254f6f46e37d852;hb=034ae114634510d7cdf7fe15e2e76ac34c1a6ddf;hp=e55f51a775b2a03b08c8aae9a67cf59fa8865a77;hpb=48e4674acd7f2ad37adef14340269f255f56c3a1;p=vlc diff --git a/src/extras/libc.c b/src/extras/libc.c index e55f51a775..1be7fe81c8 100644 --- a/src/extras/libc.c +++ b/src/extras/libc.c @@ -31,8 +31,7 @@ #include -#include - +#include #undef iconv_t #undef iconv_open @@ -49,11 +48,8 @@ #ifdef HAVE_FORK # include -# include # include -# include # include -# include # include # include # ifndef PF_LOCAL @@ -586,14 +582,15 @@ bool vlc_ureduce( unsigned *pi_dst_nom, unsigned *pi_dst_den, return b_exact; } +#undef vlc_execve /************************************************************************* * vlc_execve: Execute an external program with a given environment, * wait until it finishes and return its standard output *************************************************************************/ -int __vlc_execve( vlc_object_t *p_object, int i_argc, char *const *ppsz_argv, - char *const *ppsz_env, const char *psz_cwd, - const char *p_in, size_t i_in, - char **pp_data, size_t *pi_data ) +int vlc_execve( vlc_object_t *p_object, int i_argc, char *const *ppsz_argv, + char *const *ppsz_env, const char *psz_cwd, + const char *p_in, size_t i_in, + char **pp_data, size_t *pi_data ) { (void)i_argc; // <-- hmph #ifdef HAVE_FORK @@ -624,13 +621,11 @@ int __vlc_execve( vlc_object_t *p_object, int i_argc, char *const *ppsz_argv, /* NOTE: * Like it or not, close can fail (and not only with EBADF) */ - if ((close (0) == 0) && (close (1) == 0) && (close (2) == 0) - && (dup (fds[1]) == 0) && (dup (fds[1]) == 1) - && (open ("/dev/null", O_RDONLY) == 2) + if ((dup2 (fds[1], 0) == 0) && (dup2 (fds[1], 1) == 1) && ((psz_cwd == NULL) || (chdir (psz_cwd) == 0))) execve (ppsz_argv[0], ppsz_argv, ppsz_env); - exit (EXIT_FAILURE); + _exit (EXIT_FAILURE); } }