| 1 | /* |
| 2 | * File: Watchdog.cpp |
| 3 | * |
| 4 | * Author: Jacob Dekel |
| 5 | * Created on: Aug 7, 2009 |
| 6 | * |
| 7 | * Copyright (c) 2009-2013 Jacob Dekel |
| 8 | * $Id$ |
| 9 | * |
| 10 | * This program is free software: you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License as published by |
| 12 | * the Free Software Foundation, either version 3 of the License, or |
| 13 | * (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include "Watchdog.h"cxx . . $ `<file>/HercStudio/Watchdog.h`/ |
| 26 | #include "HerculesStudio.h"cxx . . $ `<file>/HercStudio/HerculesStudio.h`/ |
| 27 | #include "SystemUtils.h"cxx . . $ `<file>/HercUtilities/SystemUtils.h`/ |
| 28 | |
| 29 | #include <iostream> |
| 30 | #include <sstream> |
| 31 | #ifndef hFramework |
| 32 | #include <sys/wait.h> |
| 33 | #endif |
| 34 | #include <cerrno> |
| 35 | #include <sys/stat.h> |
| 36 | |
| 37 | Watchdogcxx . . $ Watchdog#::Watchdogcxx . . $ Watchdog#Watchdog(918ebd27a9ddbad3).(int herculesPid, bool child) |
| 38 | { |
| 39 | mHerculesPidcxx . . $ Watchdog#mHerculesPid. = herculesPid; |
| 40 | mChildcxx . . $ Watchdog#mChild. = child; |
| 41 | } |
| 42 | |
| 43 | Watchdogcxx . . $ Watchdog#::Watchdogcxx . . $ Watchdog#Watchdog(d95c7bd8e85c9818).(QProcesscxx . . $ QProcess# * herculesProcess) |
| 44 | { |
| 45 | mHerculesPidcxx . . $ Watchdog#mHerculesPid. = -1; |
| 46 | mChildcxx . . $ Watchdog#mChild. = false; |
| 47 | mProcesscxx . . $ Watchdog#mProcess. = herculesProcess; |
| 48 | } |
| 49 | |
| 50 | Watchdogcxx . . $ Watchdog#::~cxx . . $ Watchdog#`~Watchdog`(49f6e7a06ebc5aa8).Watchdogcxx . . $ Watchdog#() |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | void Watchdogcxx . . $ Watchdog#::runcxx . . $ Watchdog#run(49f6e7a06ebc5aa8).() |
| 55 | { |
| 56 | if (mChildcxx . . $ Watchdog#mChild.) |
| 57 | { |
| 58 | #ifndef hFramework |
| 59 | int stat_loc; |
| 60 | int rc = waitpid(mHerculesPidcxx . . $ Watchdog#mHerculesPid., &stat_loc, 0); |
| 61 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(1, "watchdog ended for pid:" << rc); |
| 62 | #endif |
| 63 | } |
| 64 | else |
| 65 | { |
| 66 | if (mHerculesPidcxx . . $ Watchdog#mHerculesPid. > 0) |
| 67 | { |
| 68 | while(SystemUtilscxx . . $ SystemUtils#::processIsRunningcxx . . $ SystemUtils#processIsRunning(83c267b20bac841a).(mHerculesPidcxx . . $ Watchdog#mHerculesPid.)) |
| 69 | sleepcxx . . $ QThread#sleep(2c44cd906ae4e829).(2); |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | while (mProcesscxx . . $ Watchdog#mProcess.->statecxx . . $ QProcess#state(12547b18370478e0).() != QProcesscxx . . $ QProcess#::NotRunningcxx . . $ QProcess#NotRunning.) |
| 74 | sleepcxx . . $ QThread#sleep(2c44cd906ae4e829).(2); |
| 75 | } |
| 76 | } |
| 77 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! HerculesEndedcxx . . $ Watchdog#HerculesEnded(49f6e7a06ebc5aa8).(); |
| 78 | } |