Fix a tiny memory-leak when calling vfork
[ardour.git] / libs / pbd / pbd / system_exec.h
index 07f7d139a786c66625eb71c456e4794ad9f90267..1e36c3df9fcba136adc0f70738d52babd5b98ef1 100644 (file)
@@ -37,6 +37,9 @@
 #undef interface // VKamyshniy: to avoid "include/giomm-2.4/giomm/dbusmessage.h:270:94: error: expected ',' or '...' before 'struct'"
 #endif
 
+#else // posix
+#include <sys/types.h>
+#include <sys/wait.h> /* WNOHANG is part of the exposed API */
 #endif
 
 #include <string>
@@ -115,7 +118,9 @@ class LIBPBD_API SystemExec
 
                virtual ~SystemExec ();
 
-               std::string GetString();
+               static char* format_key_value_parameter (std::string, std::string);
+
+               std::string to_s() const;
 
                /** fork and execute the given program
                 *
@@ -161,12 +166,19 @@ class LIBPBD_API SystemExec
                 */
                void close_stdin ();
                /** write into child-program's STDIN
-                * @param d data to write
+                * @param d text to write
                 * @param len length of data to write, if it is 0 (zero), d.length() is
                 * used to determine the number of bytes to transmit.
                 * @return number of bytes written.
                 */
-               int write_to_stdin (std::string d, size_t len=0);
+               size_t write_to_stdin (std::string const& d, size_t len=0);
+
+               /** write into child-program's STDIN
+                * @param data data to write
+                * @param bytes length of data to write
+                * @return number of bytes written.
+                */
+               size_t write_to_stdin (const void* d, size_t bytes=0);
 
                /** The ReadStdout signal is emitted when the application writes to STDOUT.
                 * it passes the written data and its length in bytes as arguments to the bound
@@ -219,6 +231,9 @@ class LIBPBD_API SystemExec
                void make_wargs(char **);
 #else
                pid_t pid;
+# ifndef NO_VFORK
+               char **argx;
+# endif
 #endif
                void init ();
                pthread_mutex_t write_lock;