diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-02-21 16:01:16 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-02-21 16:01:16 +0000 |
| commit | a1664e81dd83e11828909d10b629ed04ea7d3467 (patch) | |
| tree | ce8f13091dc7a16cd181315ea956f3f3726ab2d0 /lib/base/console.h | |
| parent | 8841c38f30a89f83ab9b89528fb90297591bd21c (diff) | |
| download | enigma2-a1664e81dd83e11828909d10b629ed04ea7d3467.tar.gz enigma2-a1664e81dd83e11828909d10b629ed04ea7d3467.zip | |
add eConsoleAppContainer to execute shell scripts or applications from python without blocking the mainloop
Diffstat (limited to 'lib/base/console.h')
| -rw-r--r-- | lib/base/console.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/base/console.h b/lib/base/console.h new file mode 100644 index 00000000..bfa02407 --- /dev/null +++ b/lib/base/console.h @@ -0,0 +1,48 @@ +#ifndef __LIB_BASE_CONSOLE_H__ +#define __LIB_BASE_CONSOLE_H__ + +#include <string> +#include <lib/base/ebase.h> +#include <lib/python/connections.h> +#include <queue> + +#ifndef SWIG +struct queue_data +{ + queue_data( char *data, int len ) + :data(data), len(len) + { + } + char *data; + int len; +}; +#endif + +class eConsoleAppContainer: public Object +{ +#ifndef SWIG + int fd[3]; + int pid; + int killstate; + std::queue<struct queue_data> outbuf; + eSocketNotifier *in, *out, *err; + void readyRead(int what); + void readyErrRead(int what); + void readyWrite(int what); + void closePipes(); +#endif +public: + eConsoleAppContainer(); + int execute( const std::string &str ); + ~eConsoleAppContainer(); + int getPID() { return pid; } + void kill(); + void sendCtrlC(); + void write( const char *data, int len ); + bool running() { return (fd[0]!=-1) && (fd[1]!=-1) && (fd[2]!=-1); } + PSignal1Str<void, const char*> dataAvail; + PSignal1<void,int> dataSent; + PSignal1<void,int> appClosed; +}; + +#endif // __LIB_BASE_CONSOLE_H__ |
