mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
Remove unused compile-time option to not use vfork
This commit is contained in:
parent
edc70200c4
commit
a9bd7b2848
4 changed files with 2 additions and 169 deletions
|
|
@ -560,14 +560,10 @@ PulseAudioBackend::control_app_name () const
|
||||||
void
|
void
|
||||||
PulseAudioBackend::launch_control_app ()
|
PulseAudioBackend::launch_control_app ()
|
||||||
{
|
{
|
||||||
#ifdef NO_VFORK
|
|
||||||
(void) system ("pavucontrol");
|
|
||||||
#else
|
|
||||||
if (::vfork () == 0) {
|
if (::vfork () == 0) {
|
||||||
::execlp ("pavucontrol", "pavucontrol", (char*)NULL);
|
::execlp ("pavucontrol", "pavucontrol", (char*)NULL);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* State Control */
|
/* State Control */
|
||||||
|
|
|
||||||
|
|
@ -70,17 +70,10 @@ PBD::open_uri (const char* uri)
|
||||||
while (s.find("\"") != std::string::npos)
|
while (s.find("\"") != std::string::npos)
|
||||||
s.replace(s.find("\\"), 1, "\\\"");
|
s.replace(s.find("\\"), 1, "\\\"");
|
||||||
|
|
||||||
#ifdef NO_VFORK
|
|
||||||
std::string command = "xdg-open ";
|
|
||||||
command += '"' + s + '"';
|
|
||||||
command += " &";
|
|
||||||
(void) system (command.c_str());
|
|
||||||
#else
|
|
||||||
if (::vfork () == 0) {
|
if (::vfork () == 0) {
|
||||||
::execlp ("xdg-open", "xdg-open", s.c_str(), (char*)NULL);
|
::execlp ("xdg-open", "xdg-open", s.c_str(), (char*)NULL);
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* not PLATFORM_WINDOWS and not __APPLE__ */
|
#endif /* not PLATFORM_WINDOWS and not __APPLE__ */
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -246,9 +246,7 @@ class LIBPBD_API SystemExec
|
||||||
void make_wargs(char **);
|
void make_wargs(char **);
|
||||||
#else
|
#else
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
# ifndef NO_VFORK
|
|
||||||
char **argx;
|
char **argx;
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
void init ();
|
void init ();
|
||||||
pthread_mutex_t write_lock;
|
pthread_mutex_t write_lock;
|
||||||
|
|
|
||||||
|
|
@ -59,103 +59,6 @@ static void * interposer_thread (void *arg);
|
||||||
static void close_fd (int& fd) { if (fd >= 0) ::close (fd); fd = -1; }
|
static void close_fd (int& fd) { if (fd >= 0) ::close (fd); fd = -1; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (!defined PLATFORM_WINDOWS && defined NO_VFORK)
|
|
||||||
/*
|
|
||||||
* This function was part of libasyncns.
|
|
||||||
* LGPL v2.1
|
|
||||||
* Copyright 2005-2008 Lennart Poettering
|
|
||||||
*/
|
|
||||||
static int close_allv(const int except_fds[]) {
|
|
||||||
struct rlimit rl;
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
|
|
||||||
DIR *d;
|
|
||||||
|
|
||||||
assert(except_fds);
|
|
||||||
|
|
||||||
if ((d = opendir("/proc/self/fd"))) {
|
|
||||||
struct dirent *de;
|
|
||||||
|
|
||||||
while ((de = readdir(d))) {
|
|
||||||
int found;
|
|
||||||
long l;
|
|
||||||
char *e = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (de->d_name[0] == '.')
|
|
||||||
continue;
|
|
||||||
|
|
||||||
errno = 0;
|
|
||||||
l = strtol(de->d_name, &e, 10);
|
|
||||||
if (errno != 0 || !e || *e) {
|
|
||||||
closedir(d);
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fd = (int) l;
|
|
||||||
|
|
||||||
if ((long) fd != l) {
|
|
||||||
closedir(d);
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd < 3)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (fd == dirfd(d))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found = 0;
|
|
||||||
for (i = 0; except_fds[i] >= 0; i++)
|
|
||||||
if (except_fds[i] == fd) {
|
|
||||||
found = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found) continue;
|
|
||||||
|
|
||||||
if (close(fd) < 0) {
|
|
||||||
int saved_errno;
|
|
||||||
|
|
||||||
saved_errno = errno;
|
|
||||||
closedir(d);
|
|
||||||
errno = saved_errno;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(d);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
for (fd = 0; fd < (int) rl.rlim_max; fd++) {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (fd <= 3)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (i = 0; except_fds[i] >= 0; i++)
|
|
||||||
if (except_fds[i] == fd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (close(fd) < 0 && errno != EBADF)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* not on windows, nor vfork */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SystemExec::init ()
|
SystemExec::init ()
|
||||||
{
|
{
|
||||||
|
|
@ -170,7 +73,7 @@ SystemExec::init ()
|
||||||
stdoutP[0] = stdoutP[1] = INVALID_HANDLE_VALUE;
|
stdoutP[0] = stdoutP[1] = INVALID_HANDLE_VALUE;
|
||||||
stderrP[0] = stderrP[1] = INVALID_HANDLE_VALUE;
|
stderrP[0] = stderrP[1] = INVALID_HANDLE_VALUE;
|
||||||
w_args = NULL;
|
w_args = NULL;
|
||||||
#elif !defined NO_VFORK
|
#else
|
||||||
argx = NULL;
|
argx = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -359,7 +262,7 @@ SystemExec::~SystemExec ()
|
||||||
}
|
}
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
if (w_args) free(w_args);
|
if (w_args) free(w_args);
|
||||||
#elif !defined NO_VFORK
|
#else
|
||||||
if (argx) {
|
if (argx) {
|
||||||
/* argx[0 .. 8] are fixed parameters to vfork-exec-wrapper */
|
/* argx[0 .. 8] are fixed parameters to vfork-exec-wrapper */
|
||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
|
|
@ -833,11 +736,7 @@ SystemExec::start (StdErrMode stderr_mode, const char *vfork_exec_wrapper)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef NO_VFORK
|
|
||||||
r = ::vfork();
|
r = ::vfork();
|
||||||
#else
|
|
||||||
r = ::fork();
|
|
||||||
#endif
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/* failed to fork */
|
/* failed to fork */
|
||||||
return -2;
|
return -2;
|
||||||
|
|
@ -887,58 +786,6 @@ SystemExec::start (StdErrMode stderr_mode, const char *vfork_exec_wrapper)
|
||||||
return 0; /* all systems go - return to main */
|
return 0; /* all systems go - return to main */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NO_VFORK
|
|
||||||
/* child process - exec external process */
|
|
||||||
close_fd (pok[0]);
|
|
||||||
::fcntl (pok[1], F_SETFD, FD_CLOEXEC);
|
|
||||||
|
|
||||||
close_fd (pin[1]);
|
|
||||||
if (pin[0] != STDIN_FILENO) {
|
|
||||||
::dup2 (pin[0], STDIN_FILENO);
|
|
||||||
}
|
|
||||||
close_fd (pin[0]);
|
|
||||||
close_fd (pout[0]);
|
|
||||||
if (pout[1] != STDOUT_FILENO) {
|
|
||||||
::dup2 (pout[1], STDOUT_FILENO);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stderr_mode == MergeWithStdin) {
|
|
||||||
/* merge STDERR into output */
|
|
||||||
if (pout[1] != STDERR_FILENO) {
|
|
||||||
::dup2(pout[1], STDERR_FILENO);
|
|
||||||
}
|
|
||||||
} else if (stderr_mode == IgnoreAndClose) {
|
|
||||||
/* ignore STDERR */
|
|
||||||
::close(STDERR_FILENO);
|
|
||||||
} else { /* stderr_mode == ShareWithParent */
|
|
||||||
/* keep STDERR */
|
|
||||||
#if defined __APPLE__&& defined ASL_LOG_DESCRIPTOR_WRITE
|
|
||||||
::close(STDERR_FILENO);
|
|
||||||
stderr_mode = IgnoreAndClose; // for vfork
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pout[1] != STDOUT_FILENO && pout[1] != STDERR_FILENO) {
|
|
||||||
close_fd(pout[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nicelevel !=0) {
|
|
||||||
::nice(nicelevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_SIGSET
|
|
||||||
sigset (SIGPIPE, SIG_DFL);
|
|
||||||
#else
|
|
||||||
signal (SIGPIPE, SIG_DFL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int good_fds[2] = { pok[1], -1 };
|
|
||||||
close_allv(good_fds);
|
|
||||||
|
|
||||||
::execve(argp[0], argp, envp);
|
|
||||||
|
|
||||||
#else /* ! NO_VFORK */
|
|
||||||
|
|
||||||
/* XXX this should be done before vfork()
|
/* XXX this should be done before vfork()
|
||||||
* calling malloc here only increases the time vfork() blocks
|
* calling malloc here only increases the time vfork() blocks
|
||||||
*/
|
*/
|
||||||
|
|
@ -966,7 +813,6 @@ SystemExec::start (StdErrMode stderr_mode, const char *vfork_exec_wrapper)
|
||||||
argx[argn+9] = NULL;
|
argx[argn+9] = NULL;
|
||||||
|
|
||||||
::execve (argx[0], argx, envp);
|
::execve (argx[0], argx, envp);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* if we reach here something went wrong.. */
|
/* if we reach here something went wrong.. */
|
||||||
char buf = 0;
|
char buf = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue