void ProcessMonitor::waitForProcess(){ //this function waits for process closing and restart process if needed do{ WaitForSingleObject(pHandle, INFINITE);//wait for process closing if (getLastAction() == LastAction::START || (getLastAction() == LastAction::RESTART && getStatus() != ProcessStatus::RESTARTING)){ //if (getLastAction() != LastAction::STOP){ //must restart process only if it was closed by itself logMessage(L"Process closed by itself", true); setProcessStatus(ProcessStatus::STOPPED);//update status crashCallbackMutex.lock(); if(onProcCrash)std::thread(onProcCrash).detach();//execute callback crashCallbackMutex.unlock(); if (!runProc()){ break;//if we can't start process back we leave } else { setProcessStatus(ProcessStatus::IS_WORKING);//if we can, update status } } else{ break;//we closed that process } } while (true); }
/** * Ajoute une action à la règle en cours d'édition (variable gloable lastRule) * \param device capteur concerné * \param state état du field du device * \param field champ du capteur concerné */ void addAction(char *device, char *state, char *field) { Action *action = malloc(sizeof(Action)); action->device = getDeviceIndex(device); action->state = getState(state); action->field = getFieldIndex(field); action->next = NULL; Action *lastAction = getLastAction(lastRule); if(lastAction == NULL) { lastRule->actions = action; } else { lastAction->next = action; } if(DEBUG_MODE == 1) { printf("New action added : %s -> %s\n", device, getStateName(getState(state))); } }