|
yast2-core
|
00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: ExternalProgram.h 00014 00015 Author: Andreas Schwab <schwab@suse.de> 00016 Maintainer: Thomas Roelz <tom@suse.de> 00017 00018 /-*/ 00019 00020 #ifndef ExternalProgram_h 00021 #define ExternalProgram_h 00022 00023 #include <map> 00024 #include <string> 00025 00026 #include <y2util/ExternalDataSource.h> 00027 #include <y2util/Pathname.h> 00028 00036 class ExternalProgram : public ExternalDataSource 00037 { 00038 00039 public: 00044 enum Stderr_Disposition { 00045 Normal_Stderr, 00046 Discard_Stderr, 00047 Stderr_To_Stdout, 00048 Stderr_To_FileDesc 00049 }; 00050 00054 typedef std::map<std::string,std::string> Environment; 00055 00064 ExternalProgram (std::string commandline, 00065 Stderr_Disposition stderr_disp = Normal_Stderr, 00066 bool use_pty = false, int stderr_fd = -1, bool default_locale = false, 00067 const Pathname& root = "", bool pty_trans = true); 00068 00074 ExternalProgram (const char *const *argv, 00075 Stderr_Disposition stderr_disp = Normal_Stderr, 00076 bool use_pty = false, int stderr_fd = -1, bool default_locale = false, 00077 const Pathname& root = "", bool pty_trans = true); 00078 00079 ExternalProgram (const char *const *argv, const Environment & environment, 00080 Stderr_Disposition stderr_disp = Normal_Stderr, 00081 bool use_pty = false, int stderr_fd = -1, bool default_locale = false, 00082 const Pathname& root = "", bool pty_trans = true); 00083 00084 ExternalProgram (const char *binpath, const char *const *argv_1, 00085 bool use_pty = false, bool pty_trans = true); 00086 00087 00088 ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment, 00089 bool use_pty = false, bool pty_trans = true); 00090 00091 00092 ~ExternalProgram(); 00093 00094 int close(); 00095 00099 bool kill(); 00100 00104 bool running(); 00105 00109 pid_t getpid() { return pid; } 00110 00114 static void renumber_fd (int origfd, int newfd); 00115 00116 protected: 00117 int checkStatus( int ); 00118 00119 private: 00120 00125 bool use_pty; 00126 00131 bool disable_pty_trans; 00132 00133 pid_t pid; 00134 int _exitStatus; 00135 00136 void start_program (const char *const *argv, const Environment & environment, 00137 Stderr_Disposition stderr_disp = Normal_Stderr, 00138 int stderr_fd = -1, bool default_locale = false, 00139 const char* root = NULL); 00140 00141 // disable LF to CRLF translation on the terminal file descriptor 00142 bool disableCRLFTranslation(int fd); 00143 }; 00144 00145 #endif // ExternalProgram_h
1.7.3