+#endif // wxUSE_GUI
+
+#if wxUSE_GUI
+ #define WXUNUSED_UNLESS_GUI(p) p
+#else
+ #define WXUNUSED_UNLESS_GUI(p)
+#endif
+
+// New wxStream classes to clean up the data when the process terminates
+
+#if wxUSE_GUI
+class wxProcessFileInputStream: public wxInputStream {
+ public:
+ wxProcessFileInputStream(int fd);
+ ~wxProcessFileInputStream();
+
+ protected:
+ size_t OnSysRead(void *buffer, size_t bufsize);
+
+ protected:
+ int m_fd;
+};
+
+class wxProcessFileOutputStream: public wxOutputStream {
+ public:
+ wxProcessFileOutputStream(int fd);
+ ~wxProcessFileOutputStream();
+
+ protected:
+ size_t OnSysWrite(const void *buffer, size_t bufsize);
+
+ protected:
+ int m_fd;
+};
+
+wxProcessFileInputStream::wxProcessFileInputStream(int fd)
+{
+ m_fd = fd;
+}
+
+wxProcessFileInputStream::~wxProcessFileInputStream()
+{
+ close(m_fd);
+}
+
+size_t wxProcessFileInputStream::OnSysRead(void *buffer, size_t bufsize)
+{
+ int ret;
+
+ ret = read(m_fd, buffer, bufsize);
+ m_lasterror = wxSTREAM_NOERROR;
+ if (ret == 0)
+ m_lasterror = wxSTREAM_EOF;
+ if (ret == -1) {
+ m_lasterror = wxSTREAM_READ_ERROR;
+ ret = 0;
+ }
+ return ret;
+}
+
+wxProcessFileOutputStream::wxProcessFileOutputStream(int fd)
+{
+ m_fd = fd;
+}
+
+wxProcessFileOutputStream::~wxProcessFileOutputStream()
+{
+ close(m_fd);
+}
+
+size_t wxProcessFileOutputStream::OnSysWrite(const void *buffer, size_t bufsize)
+{
+ int ret;
+
+ ret = write(m_fd, buffer, bufsize);
+ m_lasterror = wxSTREAM_NOERROR;
+ if (ret == -1) {
+ m_lasterror = wxSTREAM_WRITE_ERROR;
+ ret = 0;
+ }
+ return ret;
+}
+
+#endif
+
+long wxExecute(wxChar **argv,
+ bool sync,
+ wxProcess * WXUNUSED_UNLESS_GUI(process))