From 4b2b42e31f415ec8e6b6bbeb30b5c6fc35cd88f9 Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Sat, 17 Jul 2010 19:43:08 +0400 Subject: [PATCH] added native mediator runner for django run configuration to solve ctrl+break sending problem. added no-reload check-box --- native/runner/runneru/.cproject | 925 +++++++++++++++++ native/runner/runneru/.project | 71 ++ .../org.eclipse.cdt.managedbuilder.core.prefs | 14 + native/runner/runneru/runneru.cpp | 123 +++ native/runner/runnerw/.cproject | 930 ++++++++++++++++++ native/runner/runnerw/.project | 71 ++ .../org.eclipse.cdt.managedbuilder.core.prefs | 14 + .../org.eclipse.core.resources.prefs | 3 + native/runner/runnerw/runnerw.cpp | 163 +++ 9 files changed, 2314 insertions(+) create mode 100644 native/runner/runneru/.cproject create mode 100644 native/runner/runneru/.project create mode 100644 native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs create mode 100644 native/runner/runneru/runneru.cpp create mode 100644 native/runner/runnerw/.cproject create mode 100644 native/runner/runnerw/.project create mode 100644 native/runner/runnerw/.settings/org.eclipse.cdt.managedbuilder.core.prefs create mode 100644 native/runner/runnerw/.settings/org.eclipse.core.resources.prefs create mode 100644 native/runner/runnerw/runnerw.cpp diff --git a/native/runner/runneru/.cproject b/native/runner/runneru/.cproject new file mode 100644 index 000000000000..0bf8f81bacef --- /dev/null +++ b/native/runner/runneru/.cproject @@ -0,0 +1,925 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/native/runner/runneru/.project b/native/runner/runneru/.project new file mode 100644 index 000000000000..8c2fbf2e74b2 --- /dev/null +++ b/native/runner/runneru/.project @@ -0,0 +1,71 @@ + + + runneru + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/runneru/Debug} + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 000000000000..74bd0864eb02 --- /dev/null +++ b/native/runner/runneru/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,14 @@ +#Sat Jul 17 14:31:13 MSD 2010 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPLUS_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/CPLUS_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.653716760/appendContributed=true diff --git a/native/runner/runneru/runneru.cpp b/native/runner/runneru/runneru.cpp new file mode 100644 index 000000000000..bb3636095d90 --- /dev/null +++ b/native/runner/runneru/runneru.cpp @@ -0,0 +1,123 @@ +#include +#include +#include +#include +#include +#include +#include + +void PrintUsage() { + printf("Usage: runnerw.exe \n"); + printf("where is console application and it's arguments.\n"); + printf("\n"); + printf( + "Runner invokes console application as a process with inherited input and output streams.\n"); + printf( + "Input stream is scanned for presence of 2 char 255(IAC) and 243(BRK) sequence and generates Ctrl-Break event in that case.\n"); + printf( + "Also in case of all type of event(Ctrl-C, Close, Shutdown etc) Ctrl-Break event is generated."); + + exit(0); +} + +void SigintHandler(int sig) +{ + kill(0, SIGINT); + signal(SIGINT, SIG_DFL); + kill(getpid(), SIGINT); +} + +void Break(int pid) { + kill(0, SIGINT); +// kill(pid, SIGTERM); + exit(0); +} + +char IAC = 255; +char BRK = 243; + +int main(int argc, char **argv) { + if (argc < 2) { + PrintUsage(); + } + + std::string app(argv[1]); + std::string args(""); + + char* argv2[argc]; + + for (int i = 1; i < argc; i++) { + argv2[i-1]=argv[i]; + } + argv2[argc-1]=0; + + if (app.length() == 0) { + PrintUsage(); + } + + int par2child[2]; /* Pipe toward child */ + + signal(SIGINT, &SigintHandler); + + /* Open pipes */ + if (pipe(par2child) == -1) { + perror("pipe"); + exit(1); + } + + /* Fork child */ + int pid = fork(); + switch (pid) { + case -1: + perror("fork"); + exit(1); + + case 0: + /* Child section */ + + + if (dup2(par2child[0], STDIN_FILENO) == -1 + ) { + perror("dup2"); + exit(1); + } + + /* Close unused fildes. */ + close(par2child[0]); + close(par2child[1]); + + /* Exec! */ + + execv(app.c_str(), argv2); + + perror("execv"); + exit(1); + + default: + + close(par2child[0]); + + int is_iac = 0; + char buf[1]; + while (1) { + char c = fgetc(stdin); + + if (is_iac) { + if (c == BRK) { + Break(pid); + } else { + is_iac = 0; + } + } + if (c == IAC) { + is_iac = 1; + } + buf[0] = c; + write(par2child[1], buf, 1); + } + + } + + /* All done */ + return 0; +} diff --git a/native/runner/runnerw/.cproject b/native/runner/runnerw/.cproject new file mode 100644 index 000000000000..88d813ccca94 --- /dev/null +++ b/native/runner/runnerw/.cproject @@ -0,0 +1,930 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/native/runner/runnerw/.project b/native/runner/runnerw/.project new file mode 100644 index 000000000000..cc8212c4e102 --- /dev/null +++ b/native/runner/runnerw/.project @@ -0,0 +1,71 @@ + + + runnerw + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/ctrl/Debug} + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + diff --git a/native/runner/runnerw/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/native/runner/runnerw/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 000000000000..0f163f721d5d --- /dev/null +++ b/native/runner/runnerw/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,14 @@ +#Fri Jul 16 15:25:34 MSD 2010 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/CPATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/CPATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/CPLUS_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/CPLUS_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/C_INCLUDE_PATH/delimiter=; +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/C_INCLUDE_PATH/operation=remove +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/append=true +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/appendContributed=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/LIBRARY_PATH/delimiter=; +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/LIBRARY_PATH/operation=remove +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/append=true +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.exe.debug.997820937/appendContributed=true diff --git a/native/runner/runnerw/.settings/org.eclipse.core.resources.prefs b/native/runner/runnerw/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000000..a3fdc8b23f2d --- /dev/null +++ b/native/runner/runnerw/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Sat Jul 17 17:27:10 MSD 2010 +eclipse.preferences.version=1 +encoding/runnerw.cpp=Cp1251 diff --git a/native/runner/runnerw/runnerw.cpp b/native/runner/runnerw/runnerw.cpp new file mode 100644 index 000000000000..d1d8031598e7 --- /dev/null +++ b/native/runner/runnerw/runnerw.cpp @@ -0,0 +1,163 @@ +#include +#include +#include +#include +#include + +void PrintUsage() { + printf("Usage: runnerw.exe \n"); + printf("where is console application and it's arguments.\n"); + printf("\n"); + printf("Runner invokes console application as a process with inherited input and output streams.\n"); + printf("Input stream is scanned for presence of 2 char 255(IAC) and 243(BRK) sequence and generates Ctrl-Break event in that case.\n"); + printf("Also in case of all type of event(Ctrl-C, Close, Shutdown etc) Ctrl-Break event is generated."); + + exit(0); +} + +void ErrorMessage(char *str) { + + LPVOID msg; + + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &msg, 0, NULL); + + printf("%s: %s\n", str, msg); + LocalFree(msg); +} + +void CtrlBreak() { + if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, 0)) { + ErrorMessage("GenerateConsoleCtrlEvent"); + } +} + +BOOL is_iac = FALSE; + +char IAC = 255; +char BRK = 243; + +BOOL Scan(char buf[], int count) { + for (int i = 0; i