15.10.2012 - version 0.2.0 - PIIODevice - base of file, ethernet, serial and packets extractor. PIEthernet now support also TCP (client and server). PIConsole now can align labels in each column individually.
This commit is contained in:
20
piprocess.h
Normal file → Executable file
20
piprocess.h
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Process
|
||||
Copyright (C) 2011 Ivan Pelipenko peri4ko@gmail.com
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -33,14 +33,14 @@ class PIProcess: private PIThread
|
||||
public:
|
||||
PIProcess();
|
||||
~PIProcess();
|
||||
|
||||
|
||||
int exitCode() const {return exit_code;}
|
||||
#ifdef WINDOWS
|
||||
int pID() const {return pi.dwProcessId;}
|
||||
#else
|
||||
int pID() const {return pid;}
|
||||
#endif
|
||||
|
||||
|
||||
void setGrabInput(bool yes) {g_in = yes;}
|
||||
void setGrabOutput(bool yes) {g_out = yes;}
|
||||
void setGrabError(bool yes) {g_err = yes;}
|
||||
@@ -64,25 +64,25 @@ public:
|
||||
void terminate() {if (is_exec) kill(pid, SIGKILL); pid = 0;}
|
||||
#endif
|
||||
bool waitForFinish(int timeout_msecs = 60000) {return PIThread::waitForFinish(timeout_msecs);}
|
||||
PIByteArray readOutput() {f_out.open(PIFile::Read); return f_out.readAll();}
|
||||
PIByteArray readError() {f_err.open(PIFile::Read); return f_err.readAll();}
|
||||
|
||||
PIByteArray readOutput() {f_out.open(PIIODevice::ReadOnly); return f_out.readAll();}
|
||||
PIByteArray readError() {f_err.open(PIIODevice::ReadOnly); return f_err.readAll();}
|
||||
|
||||
PIStringList environment() {return env;}
|
||||
void clearEnvironment() {env.clear();}
|
||||
void removeEnvironmentVariable(const PIString & variable);
|
||||
void setEnvironmentVariable(const PIString & variable, const PIString & value);
|
||||
|
||||
|
||||
static PIStringList currentEnvironment() {PIStringList l; int i = 0; while (environ[i] != 0) {l << environ[i]; ++i;} return l;}
|
||||
#ifdef WINDOWS
|
||||
static int currentPID() {return GetCurrentProcessId();}
|
||||
#else
|
||||
static int currentPID() {return getpid();}
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
virtual void run();
|
||||
void exec_();
|
||||
|
||||
|
||||
PIStringList args, env;
|
||||
PIString wd;
|
||||
PIByteArray out;
|
||||
@@ -96,7 +96,7 @@ private:
|
||||
#endif
|
||||
int exit_code, sz;
|
||||
bool is_exec;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // PIPROCESS_H
|
||||
|
||||
Reference in New Issue
Block a user