00001 /* $Id: ProcessRunner.h 567 2007-12-02 08:24:03Z mindstorm2600 $ */ 00002 /* 00003 * This program is free software; you can redistribute it and/or modify 00004 * it under the terms of the GNU General Public License as published by 00005 * the Free Software Foundation; either version 2 of the License, or 00006 * (at your option) any later version. 00007 * 00008 * This program is distributed in the hope that it will be useful, 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 * GNU General Public License for more details. 00012 * 00013 * You should have received a copy of the GNU General Public License 00014 * along with this program; if not, write to the Free Software 00015 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00016 */ 00017 00018 #ifndef __XVR2_PLATFORM_PROCESS_RUNNER_H__ 00019 #define __XVR2_PLATFORM_PROCESS_RUNNER_H__ 00020 00021 #include<xvr2/SystemException.h> 00022 #include<xvr2/Platform/PlatformException.h> 00023 #include<xvr2/RawInputStream.h> 00024 #include<xvr2/RawOutputStream.h> 00025 #include<xvr2/String.h> 00026 #include<xvr2/Buffer.h> 00027 00028 namespace xvr2 { 00029 namespace Platform { 00030 00034 class ProcessRunner:public Object { 00035 protected: 00036 RawInputStream err; 00037 RawInputStream out; 00038 RawOutputStream in; 00039 void *stack; 00040 public: 00041 ProcessRunner(); 00042 ProcessRunner(const String &_cmdline); 00043 ~ProcessRunner(); 00044 void start(); 00045 void start(const String &cmdline); 00046 RawInputStream &errorStream(); 00047 RawInputStream &outputStream(); 00048 RawOutputStream &inputStream(); 00051 int exitCode(); 00053 Int32 pid(); 00054 void kill(int signal); 00055 int wait(); 00056 bool isRunning(); 00057 00058 static int execute(const String &command); 00059 static int execute(const String &command, Buffer &_output); 00060 }; 00061 00062 class ProcessException : public SystemException { 00063 protected: 00064 String _comment; 00065 public: 00066 ProcessException(int c); 00067 ProcessException(int c, const String &msg); 00068 const String &comment(); 00069 }; 00070 }; 00071 }; 00072 00073 #endif