X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fpbd%2Fsystem_exec.h;h=a8a30ba18dc0b6af05faac7aacc5f68cd4f1b76b;hb=f290be21ee896912553efbe5ec7f75d1d027ac13;hp=0ca523085ae05991e590f37ad64a410663230d0c;hpb=912f07b919c1ec44f0cdd5278d74a9bc29b91846;p=ardour.git diff --git a/libs/pbd/pbd/system_exec.h b/libs/pbd/pbd/system_exec.h index 0ca523085a..a8a30ba18d 100644 --- a/libs/pbd/pbd/system_exec.h +++ b/libs/pbd/pbd/system_exec.h @@ -37,11 +37,16 @@ #undef interface // VKamyshniy: to avoid "include/giomm-2.4/giomm/dbusmessage.h:270:94: error: expected ',' or '...' before 'struct'" #endif +#else // posix +#include +#include /* WNOHANG is part of the exposed API */ #endif #include #include #include +#include + #ifdef NOPBD /* unit-test outside ardour */ #include #include @@ -94,8 +99,27 @@ class LIBPBD_API SystemExec * */ SystemExec (std::string c, char ** a); + + /** similar to \ref SystemExec but expects a whole command line, and + * handles some simple escape sequences. + * + * @param command complete command-line to be executed + * @param subs a map of listing the % substitutions to + * be made. + * + * creates an argv array from the given command string, splitting into + * parameters at spaces. + * "\ " is non-splitting space, "\\" (and "\" at end of command) as "\", + * for "%", is looked up in subs and the corresponding string + * substituted. "%%" (and "%" at end of command) + * returns an argv array suitable for creating a new SystemExec with + */ + SystemExec (std::string command, const std::map subs); + virtual ~SystemExec (); + std::string to_s() const; + /** fork and execute the given program * * @param stderr_mode select what to do with program's standard error @@ -107,7 +131,7 @@ class LIBPBD_API SystemExec * @return If the process is already running or was launched successfully * the function returns zero (0). A negative number indicates an error. */ - int start (int stderr_mode = 1); + int start (int stderr_mode, const char *_vfork_exec_wrapper); /** kill running child-process * * if a child process exists trt to shut it down by closing its STDIN. @@ -182,6 +206,7 @@ class LIBPBD_API SystemExec int nicelevel; ///< process nice level - defaults to 0 void make_argp(std::string); + void make_argp_escaped(std::string command, const std::map subs); void make_envp(); char **argp; @@ -198,9 +223,9 @@ class LIBPBD_API SystemExec #else pid_t pid; #endif + void init (); pthread_mutex_t write_lock; - int fdin; ///< file-descriptor for writing to child's STDIN. This variable is identical to pin[1] but also used as status check if the stdin pipe is open: <0 means closed. int pok[2]; int pin[2]; int pout[2];