1 /*
2 * Copyright (C) 2014-2015 Robin Gareus <robin@gareus.org>
3 * Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include <glibmm/miscutils.h>
21 #include "pbd/file_utils.h"
22 #include "pbd/error.h"
23
24 #include "ardour/filesystem_paths.h"
25 #include "ardour/system_exec.h"
26
27 namespace ARDOUR {
28
29 char * SystemExec::_vfork_exec_wrapper = NULL;
30
vfork_exec_wrapper_path()31 static char *vfork_exec_wrapper_path() {
32 #ifdef PLATFORM_WINDOWS
33 return NULL;
34 #else
35 std::string vfork_exec_wrapper;
36 if (!PBD::find_file (
37 PBD::Searchpath(
38 ARDOUR::ardour_dll_directory() // deployed
39 + G_SEARCHPATH_SEPARATOR_S + Glib::build_filename(ARDOUR::ardour_dll_directory(), "vfork") // src, build (ardev, etc)
40 ),
41 "ardour-exec-wrapper", vfork_exec_wrapper)) {
42 PBD::fatal << "vfork exec wrapper 'ardour-exec-wrapper' was not found in $PATH." << endmsg;
43 abort(); /*NOTREACHED*/
44 }
45 return strdup(vfork_exec_wrapper.c_str());
46 #endif
47 }
48
SystemExec(std::string c,char ** a)49 SystemExec::SystemExec (std::string c, char ** a)
50 : PBD::SystemExec(c, a)
51 {
52 #ifndef PLATFORM_WINDOWS
53 if (!_vfork_exec_wrapper) {
54 _vfork_exec_wrapper = vfork_exec_wrapper_path();
55 }
56 #endif
57 }
58
SystemExec(std::string c,std::string a)59 SystemExec::SystemExec (std::string c, std::string a)
60 : PBD::SystemExec(c, a)
61 {
62 #ifndef PLATFORM_WINDOWS
63 if (!_vfork_exec_wrapper) {
64 _vfork_exec_wrapper = vfork_exec_wrapper_path();
65 }
66 #endif
67 }
68
SystemExec(std::string c,const std::map<char,std::string> subs)69 SystemExec::SystemExec (std::string c, const std::map<char, std::string> subs)
70 : PBD::SystemExec(c, subs)
71 {
72 #ifndef PLATFORM_WINDOWS
73 if (!_vfork_exec_wrapper) {
74 _vfork_exec_wrapper = vfork_exec_wrapper_path();
75 }
76 #endif
77 }
78
~SystemExec()79 SystemExec::~SystemExec() { }
80
81 } // namespace ARDOUR
82