version 0.5.0_alpha

git-svn-id: svn://db.shs.com.ru/pip@8 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
2015-03-10 10:13:18 +00:00
parent b1f651ab62
commit c11bc3b3b8
697 changed files with 18150 additions and 18839 deletions

View File

@@ -4,7 +4,7 @@
/*
PIP - Platform Independent Primitives
Process
Copyright (C) 2014 Ivan Pelipenko peri4ko@gmail.com
Copyright (C) 2015 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
@@ -25,11 +25,6 @@
#include "pithread.h"
#include "pifile.h"
#ifdef WINDOWS
//# include <.h>
#else
# include <sys/wait.h>
#endif
/// events:
/// execStarted(PIString program)
@@ -51,13 +46,7 @@ public:
virtual ~PIProcess();
int exitCode() const {return exit_code;}
int pID() const {
#ifdef WINDOWS
return pi.dwProcessId;
#else
return pid;
#endif
}
int pID() const;
void setGrabInput(bool yes) {g_in = yes;}
void setGrabOutput(bool yes) {g_out = yes;}
@@ -84,27 +73,15 @@ public:
EVENT_HANDLER3(void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2) {args.clear(); args << program << arg1 << arg2; exec_();}
EVENT_HANDLER4(void, exec, const PIString & , program, const PIString & , arg1, const PIString & , arg2, const PIString & , arg3) {args.clear(); args << program << arg1 << arg2 << arg3; exec_();}
EVENT_HANDLER2(void, exec, const PIString & , program, const PIStringList & , args_) {args << program << args_; exec_();}
EVENT_HANDLER(void, terminate) {
#ifdef WINDOWS
if (is_exec) if (!TerminateProcess(pi.hProcess, 0)) return; pi.dwProcessId = 0;
#else
if (is_exec) kill(pid, SIGKILL); pid = 0;
#endif
}
EVENT_HANDLER(void, terminate);
EVENT_HANDLER(bool, waitForFinish) {return waitForFinish(60000);}
EVENT_HANDLER1(bool, waitForFinish, int, timeout_msecs) {return PIThread::waitForFinish(timeout_msecs);}
EVENT1(execStarted, PIString, program)
EVENT2(execFinished, PIString, program, int, exit_code)
static PIStringList currentEnvironment() {PIStringList l; int i = 0; while (environ[i] != 0) {l << environ[i]; ++i;} return l;}
static int currentPID() {
#ifdef WINDOWS
return GetCurrentProcessId();
#else
return getpid();
#endif
}
static PIStringList currentEnvironment();
static int currentPID();
private:
virtual void run();