yast2-core
ExternalProgram.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
8 | |
9 | core system |
10 | (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12 
13  File: ExternalProgram.h
14 
15  Author: Andreas Schwab <schwab@suse.de>
16  Maintainer: Thomas Roelz <tom@suse.de>
17 
18 /-*/
19 
20 #ifndef ExternalProgram_h
21 #define ExternalProgram_h
22 
23 #include <map>
24 #include <string>
25 
27 #include <y2util/Pathname.h>
28 
37 {
38 
39 public:
49  };
50 
54  typedef std::map<std::string,std::string> Environment;
55 
64  ExternalProgram (std::string commandline,
65  Stderr_Disposition stderr_disp = Normal_Stderr,
66  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
67  const Pathname& root = "", bool pty_trans = true);
68 
74  ExternalProgram (const char *const *argv,
75  Stderr_Disposition stderr_disp = Normal_Stderr,
76  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
77  const Pathname& root = "", bool pty_trans = true);
78 
79  ExternalProgram (const char *const *argv, const Environment & environment,
80  Stderr_Disposition stderr_disp = Normal_Stderr,
81  bool use_pty = false, int stderr_fd = -1, bool default_locale = false,
82  const Pathname& root = "", bool pty_trans = true);
83 
84  ExternalProgram (const char *binpath, const char *const *argv_1,
85  bool use_pty = false, bool pty_trans = true);
86 
87 
88  ExternalProgram (const char *binpath, const char *const *argv_1, const Environment & environment,
89  bool use_pty = false, bool pty_trans = true);
90 
91 
93 
94  int close();
95 
99  bool kill();
100 
104  bool running();
105 
109  pid_t getpid() { return pid; }
110 
114  static void renumber_fd (int origfd, int newfd);
115 
116 protected:
117  int checkStatus( int );
118 
119 private:
120 
125  bool use_pty;
126 
132 
133  pid_t pid;
135 
136  void start_program (const char *const *argv, const Environment & environment,
137  Stderr_Disposition stderr_disp = Normal_Stderr,
138  int stderr_fd = -1, bool default_locale = false,
139  const char* root = NULL);
140 
141  // disable LF to CRLF translation on the terminal file descriptor
142  bool disableCRLFTranslation(int fd);
143 };
144 
145 #endif // ExternalProgram_h
int close()
Definition: ExternalProgram.cc:326
int _exitStatus
Definition: ExternalProgram.h:134
bool disableCRLFTranslation(int fd)
Definition: ExternalProgram.cc:125
ExternalProgram(std::string commandline, Stderr_Disposition stderr_disp=Normal_Stderr, bool use_pty=false, int stderr_fd=-1, bool default_locale=false, const Pathname &root="", bool pty_trans=true)
Definition: ExternalProgram.cc:37
pid_t getpid()
Definition: ExternalProgram.h:109
int checkStatus(int)
Definition: ExternalProgram.cc:354
Definition: Pathname.h:31
bool running()
Definition: ExternalProgram.cc:402
Definition: ExternalProgram.h:47
Stderr_Disposition
Definition: ExternalProgram.h:44
void start_program(const char *const *argv, const Environment &environment, Stderr_Disposition stderr_disp=Normal_Stderr, int stderr_fd=-1, bool default_locale=false, const char *root=NULL)
Definition: ExternalProgram.cc:158
static void renumber_fd(int origfd, int newfd)
Definition: ExternalProgram.cc:425
std::map< std::string, std::string > Environment
Definition: ExternalProgram.h:54
Execute a program and give access to its io An object of this class encapsulates the execution of an ...
Definition: ExternalProgram.h:36
bool kill()
Definition: ExternalProgram.cc:390
Definition: ExternalProgram.h:48
pid_t pid
Definition: ExternalProgram.h:133
bool disable_pty_trans
Definition: ExternalProgram.h:131
Definition: ExternalProgram.h:46
Bidirectional stream to external data.
Definition: ExternalDataSource.h:30
~ExternalProgram()
Definition: ExternalProgram.cc:119
Definition: ExternalProgram.h:45
bool use_pty
Definition: ExternalProgram.h:125

Generated on a sunny day for yast2-core by doxygen 1.8.5