Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ExternalProgram.h

Go to the documentation of this file.
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 = "");
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 = "");
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 = "");
00083 
00084     ExternalProgram (const char *binpath, const char *const *argv_1,
00085                      bool use_pty = false);
00086 
00087 
00088     ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
00089                      bool use_pty = false);
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 
00127     pid_t pid;
00128     int _exitStatus;
00129 
00130     void start_program (const char *const *argv, const Environment & environment,
00131                         Stderr_Disposition stderr_disp = Normal_Stderr,
00132                         int stderr_fd = -1, bool default_locale = false,
00133                         const char* root = NULL);
00134 
00135 };
00136 
00137 #endif // ExternalProgram_h

Generated on Fri Feb 24 00:30:02 2006 for liby2util by  doxygen 1.4.4