This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2goclient. commit 3d76d001c18fef4f88cb98c598a5841be4d7ee96 Author: Oleksandr Shneyder <o.shneyder@phoca-gmbh.de> Date: Tue Jul 8 11:51:05 2014 +0200 Add x2gohelper to start X2Go Client on Windows and clean child processes if X2Go Client crashes. --- config_win.bat | 5 ++- debian/changelog | 2 + ongetpass.cpp | 78 --------------------------------------- onmainwindow.cpp | 6 --- x2gohelper/x2gohelper.cpp | 90 +++++++++++++++++++++++++++++++++++++++++++++ x2gohelper/x2gohelper.pro | 14 +++++++ 6 files changed, 110 insertions(+), 85 deletions(-) diff --git a/config_win.bat b/config_win.bat index 695b3e2..8bd1f36 100755 --- a/config_win.bat +++ b/config_win.bat @@ -2,4 +2,7 @@ mingw32-make distclean lrelease x2goclient.pro set X2GO_CLIENT_TARGET= qmake - +cd x2gohelper +mingw32-make distclean +qmake +cd .. diff --git a/debian/changelog b/debian/changelog index f4e8419..2916b7d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -53,6 +53,8 @@ x2goclient (4.0.2.1-0x2go1) UNRELEASED; urgency=low - Update string "&Clipboard Mode" and translate in russian translation file. - Grammar fix in russian translation. - Fix "fullscreen" mode on Windows 7 with multiple monitors. + - Add x2gohelper to start X2Go Client on Windows and clean child processes if + X2Go Client crashes. [ Mike DePaulo ] * New upstream release (4.0.2.1): diff --git a/ongetpass.cpp b/ongetpass.cpp index 3d65b2e..e88cbe5 100644 --- a/ongetpass.cpp +++ b/ongetpass.cpp @@ -33,11 +33,8 @@ #ifndef Q_OS_WIN #include <sys/types.h> #include <signal.h> -#else -#include <iostream> #endif - #include <QPlastiqueStyle> #include <QMessageBox> #include <iostream> @@ -45,54 +42,8 @@ #include <QProcess> #include <QLocalSocket> #include "x2gologdebug.h" -using namespace std; - -#ifdef Q_OS_WIN -#include <TlHelp32.h> -void killProcess(DWORD pid) -{ - HANDLE handle=OpenProcess(PROCESS_TERMINATE,0,pid); - if(!handle) - { -// qCritical()<<"failed to open process"; - return; - } - if(!TerminateProcess(handle,0)) - { -// qCritical()<<"failed to terminate process"; - return; - } - CloseHandle(handle); -// qCritical()<<pid<<" terminated"; -} - -void enumerateFromParent(DWORD pid) -{ - HANDLE hndl=CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); - if(hndl==INVALID_HANDLE_VALUE) - { - qCritical()<<"failed to get system snapshot"; - return; - } - PROCESSENTRY32 pentry; - pentry.dwSize = sizeof( PROCESSENTRY32 ); - if( Process32First(hndl,&pentry)) - { - while(Process32Next(hndl,&pentry)) - { - if(pid==pentry.th32ParentProcessID) - { - enumerateFromParent(pentry.th32ProcessID); -// qCritical()<<"terminating "<<pentry.th32ProcessID<<":"<<QString::fromWCharArray ( pentry.szExeFile); - killProcess(pentry.th32ProcessID); - } - } - } - CloseHandle(hndl); -} -#endif int x2goMain ( int argc, char *argv[] ) { @@ -150,35 +101,6 @@ int x2goMain ( int argc, char *argv[] ) #ifdef CFGCLIENT else { -#ifdef Q_OS_WIN - if(argc <=1) - { - args=app.arguments(); - } - if(args.count()<2 || args[1].indexOf("--child-process")==-1) - { - QProcess proc; - QString executable=args[0]; - args.pop_front(); - args.push_front("--child-process"); - proc.start(executable, args); - if(!proc.waitForStarted(4000)) - { - qCritical()<<"Can't start process"; - return -1; - } - DWORD pid=proc.pid()->dwProcessId; - while(!proc.waitForFinished(300)) - { - QString err=proc.readAllStandardError(); - QString out=proc.readAllStandardOutput(); - std::cerr<<err.toStdString(); - std::cout<<out.toStdString(); - } - enumerateFromParent(pid); - return 0; - } -#endif //Q_OS_WIN ONMainWindow* mw = new ONMainWindow; mw->show(); return app.exec(); diff --git a/onmainwindow.cpp b/onmainwindow.cpp index 05ed0d9..8390cbe 100644 --- a/onmainwindow.cpp +++ b/onmainwindow.cpp @@ -6786,12 +6786,6 @@ bool ONMainWindow::parseParameter ( QString param ) closeDisconnect=true; return true; } -#ifdef Q_OS_WIN - if ( param=="--child-process" ) - { - return true; - } -#endif QString setting,value; QStringList vals=param.split ( "=" ); diff --git a/x2gohelper/x2gohelper.cpp b/x2gohelper/x2gohelper.cpp new file mode 100644 index 0000000..5f0bd42 --- /dev/null +++ b/x2gohelper/x2gohelper.cpp @@ -0,0 +1,90 @@ +/************************************************************************** +* Copyright (C) 2005-2014 by Oleksandr Shneyder * +* o.shneyder@phoca-gmbh.de * +* * +* 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 * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU General Public License * +* along with this program. If not, see <http://www.gnu.org/licenses/>. * +***************************************************************************/ +#include <iostream> +using namespace std; +#include <windows.h> +#include <TlHelp32.h> + +#include <QStringList> +#include <QProcess> +#include <QDebug> + +void killProcess(DWORD pid) +{ + HANDLE handle=OpenProcess(PROCESS_TERMINATE,0,pid); + if(!handle) + { + return; + } + if(!TerminateProcess(handle,0)) + { + return; + } + CloseHandle(handle); +} + +void enumerateFromParent(DWORD pid) +{ + HANDLE hndl=CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); + if(hndl==INVALID_HANDLE_VALUE) + { + qCritical()<<"failed to get system snapshot"; + return; + } + PROCESSENTRY32 pentry; + pentry.dwSize = sizeof( PROCESSENTRY32 ); + if( Process32First(hndl,&pentry)) + { + while(Process32Next(hndl,&pentry)) + { + if(pid==pentry.th32ParentProcessID) + { + enumerateFromParent(pentry.th32ProcessID); + killProcess(pentry.th32ProcessID); + } + } + } + CloseHandle(hndl); +} + +int main(int argc, char* argv[]) +{ + QStringList args; + //argv[0] is allways "x2gohelper.exe" + for(int i=1; i< argc; ++i) + { + args<<argv[i]; + } + QProcess proc; + QString executable="x2goclient.exe"; + proc.start(executable, args); + if(!proc.waitForStarted(4000)) + { + qCritical()<<"Can't start process"; + return -1; + } + DWORD pid=proc.pid()->dwProcessId; + while(!proc.waitForFinished(300)) + { + QString err=proc.readAllStandardError(); + QString out=proc.readAllStandardOutput(); + std::cerr<<err.toStdString(); + std::cout<<out.toStdString(); + } + enumerateFromParent(pid); + return 0; +} diff --git a/x2gohelper/x2gohelper.pro b/x2gohelper/x2gohelper.pro new file mode 100644 index 0000000..1ac685e --- /dev/null +++ b/x2gohelper/x2gohelper.pro @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Di. Jul 8 10:58:26 2014 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += x2gohelper.cpp +QT -= gui +CONFIG += static release +#CONFIG += console -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git