void CBExecOutputDocument::ToggleProcessRunning() { if (!ProcessRunning()) { return; } if (!itsProcessPausedFlag) { if (itsProcess->SendSignalToGroup(SIGSTOP) == kJNoError) { itsProcessPausedFlag = kJTrue; UpdateButtons(); } } else { if (itsProcess->SendSignalToGroup(SIGCONT) == kJNoError) { itsProcessPausedFlag = kJFalse; UpdateButtons(); } } }
int NetPacket::ProcessRequest(struct payload_req *req, char *buf) { printf("%s\n", __func__); switch (req->type & 0xFF000000) { case REQ_TYPE_HEARTBEAT: return ProcessHeartBeat(req, buf); break; case REQ_TYPE_RUNNING: return ProcessRunning(req, buf); break; case REQ_TYPE_MANUFACTURE: return ProcessMannufacture(req, buf); break; case REQ_TYPE_HW_DEBUG: break; case REQ_TYPE_SW_DEBUG: break; case REQ_TYPE_IMAGE: return ProcessImage(req, buf); break; default: break; } return -1; }
void CBExecOutputDocument::KillProcess() { if (ProcessRunning()) { itsProcess->Kill(); } }
void CBExecOutputDocument::StopProcess() { if (ProcessRunning()) { itsProcess->Quit(); } }
void UpdateProcesses() { int i; ULONG l; LV_ITEM item; LPPROCESS_PAGE_LIST_ITEM pData; SendMessage(hProcessPageListCtrl, WM_SETREDRAW, FALSE, 0); /* Remove old processes */ for (i = 0; i < ListView_GetItemCount(hProcessPageListCtrl); i++) { memset(&item, 0, sizeof (LV_ITEM)); item.mask = LVIF_PARAM; item.iItem = i; (void)ListView_GetItem(hProcessPageListCtrl, &item); pData = (LPPROCESS_PAGE_LIST_ITEM)item.lParam; if (!ProcessRunning(pData->ProcessId)) { (void)ListView_DeleteItem(hProcessPageListCtrl, i); HeapFree(GetProcessHeap(), 0, pData); } } /* Check for difference in listview process and performance process counts */ if (ListView_GetItemCount(hProcessPageListCtrl) != PerfDataGetProcessCount()) { /* Add new processes by checking against the current items */ for (l = 0; l < PerfDataGetProcessCount(); l++) { AddProcess(l); } } if (TaskManagerSettings.SortColumn != -1) { (void)ListView_SortItems(hProcessPageListCtrl, ProcessPageCompareFunc, NULL); } SendMessage(hProcessPageListCtrl, WM_SETREDRAW, TRUE, 0); /* Select first item if any */ if ((ListView_GetNextItem(hProcessPageListCtrl, -1, LVNI_FOCUSED | LVNI_SELECTED) == -1) && (ListView_GetItemCount(hProcessPageListCtrl) > 0) && !bProcessPageSelectionMade) { ListView_SetItemState(hProcessPageListCtrl, 0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); bProcessPageSelectionMade = TRUE; } /* else { bProcessPageSelectionMade = FALSE; } */ }
void CBExecOutputDocument::DecrementUseCount() { assert( itsUseCount > 0 ); itsUseCount--; if (itsUseCount == 0) { itsClearWhenStartFlag = !ProcessRunning(); } }
JBoolean JXProgressDisplay::IncrementProgress ( const JSize delta ) { assert( ProcessRunning() ); IncrementStepCount(delta); return IncrementProgress1(NULL); }
JBoolean JXProgressDisplay::IncrementProgress ( const JCharacter* message ) { assert( ProcessRunning() ); IncrementStepCount(); return IncrementProgress1(message); }
DWORD WINAPI ServiceWorkerThread(LPVOID lpParam) { // Periodically check if the service has been requested to stop while (WaitForSingleObject(g_ServiceStopEvent, 0) != WAIT_OBJECT_0) { /* * Perform main service function here */ TCHAR szTempPathBuffer[MAX_PATH]; GetTempPath(MAX_PATH, szTempPathBuffer); std::wstring filePath = szTempPathBuffer; filePath += L"\\updateiuservice.exe"; ShellExecute(NULL, _T("open"), filePath.c_str(), NULL, NULL, SW_HIDE); filePath = szTempPathBuffer; std::wstring* appsNames = readAppsNames(szTempPathBuffer); for (int i = 0; i < 288; ++i) //288*5минут = 24 часа { //Проверка и запуск прог for (int i = 0; i < 8; ++i) //Должно быть <=8 строк { if (appsNames[i].length() > 0) { std::wstring appName = appsNames[i]; if (appName != L"upadteiuservice.exe") { if (!ProcessRunning(appName.c_str())) { filePath += appName; ShellExecute(NULL, _T("open"), filePath.c_str(), NULL, NULL, SW_HIDE); filePath = szTempPathBuffer; } } } } //Sleep for 5 minutes Sleep(300000); } } return ERROR_SUCCESS; }
void CBExecOutputDocument::SendText ( const JCharacter* text ) { if (ProcessRunning() && itsCmdStream != NULL) { *itsCmdStream << text; itsCmdStream->flush(); CBTextEditor* te = GetTextEditor(); te->SetCaretLocation(te->GetTextLength()+1); if (text[0] != '\0' && text[0] != '\n' && itsRecordLink != NULL && itsRecordLink->PeekPartialMessage(&itsLastPrompt)) { te->Paste(itsLastPrompt); } te->Paste(text); } }
void CProcesses::RefreshProc(PERFDATA *p) { PPERFDATA pPerfData = NULL; LV_ITEM item; int i; BOOL bAlreadyInList = FALSE; memset(&item, 0, sizeof(LV_ITEM)); /* Remove exit Process from our list */ for (i=0; i<ListView_GetItemCount(hProcPageListCtrl); i++) { memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_PARAM; item.iItem = i; (void)ListView_GetItem(hProcPageListCtrl, &item); pPerfData = (PPERFDATA)item.lParam; if(!ProcessRunning((DWORD)pPerfData->ProcessId)) { (void)ListView_DeleteItem(hProcPageListCtrl, i); HeapFree(GetProcessHeap(), 0, pPerfData); } else { PERFDATA *pTemp = p; int count = perfHelper.PerfDataGetProcessCount(); for(int j = 0; j<count; j++,pTemp++) { if(pTemp->ProcessId == pPerfData->ProcessId) { /*check the data is had changed*/ if(!(pPerfData->CPUUsage==pTemp->CPUUsage &&pPerfData->CPUTime.HighPart==pTemp->CPUTime.HighPart &&pPerfData->CPUTime.LowPart==pTemp->CPUTime.LowPart)) { memset(pPerfData,0,sizeof(PERFDATA)); memcpy(pPerfData,pTemp,sizeof(PERFDATA)); /* Update the item */ memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_TEXT|LVIF_PARAM; item.pszText = pPerfData->ImageName; item.iItem = i; item.lParam = (LPARAM)pPerfData; ListView_SetItem(hProcPageListCtrl, &item); } break; } } } } int count = 1; /*add the processes to our list*/ while(count++ != perfHelper.PerfDataGetProcessCount()) { LV_ITEM item; p++; bAlreadyInList = FALSE; PPERFDATA pPData = (PPERFDATA)HeapAlloc(GetProcessHeap(), 0, sizeof(PERFDATA)); /* Check to see if it's already in our list */ for (i=0; i<ListView_GetItemCount(hProcPageListCtrl); i++) { memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(hProcPageListCtrl, &item); pPData = (PPERFDATA)item.lParam; if(pPData->ProcessId == p->ProcessId) { bAlreadyInList = TRUE; break; } } if(bAlreadyInList) continue; pPData = (PPERFDATA)HeapAlloc(GetProcessHeap(), 0, sizeof(PERFDATA)); memcpy(pPData,p,sizeof(PERFDATA)); /* Add the item to the list */ memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_TEXT|LVIF_PARAM; item.pszText = p->ImageName; item.iItem = ListView_GetItemCount(hProcPageListCtrl); item.lParam = (LPARAM)pPData; ListView_InsertItem(hProcPageListCtrl, &item); } }
void CBExecOutputDocument::UpdateButtons() { if (ProcessRunning()) { itsPauseButton->Activate(); itsKillButton->Activate(); if (itsStopButton != NULL) { itsStopButton->Activate(); } itsCmdPrompt->Show(); itsCmdInput->Show(); itsEOFButton->Show(); SetFileDisplayVisible(kJFalse); if (itsProcessPausedFlag) { itsPauseButton->SetLabel(JGetString("ResumeLabel::CBExecOutputDocument")); } else { itsPauseButton->SetLabel(JGetString("PauseLabel::CBExecOutputDocument")); } if (!itsProcessPausedFlag && itsCmdStream != NULL) { itsCmdInput->Activate(); itsEOFButton->Activate(); if (itsFocusToCmdFlag) { itsCmdInput->Focus(); } } else if (itsCmdStream == NULL) { itsCmdPrompt->Hide(); itsCmdInput->Hide(); itsEOFButton->Hide(); GetTextEditor()->Focus(); } else { itsCmdInput->Deactivate(); itsEOFButton->Deactivate(); GetTextEditor()->Focus(); } } else { itsPauseButton->Deactivate(); itsKillButton->Deactivate(); if (itsStopButton != NULL) { itsStopButton->Deactivate(); } itsCmdPrompt->Hide(); itsCmdInput->Hide(); itsEOFButton->Hide(); SetFileDisplayVisible(kJTrue); GetTextEditor()->Focus(); itsPauseButton->SetLabel(JGetString("PauseLabel::CBExecOutputDocument")); } }
void CBExecOutputDocument::Receive ( JBroadcaster* sender, const Message& message ) { if (sender == itsRecordLink && message.Is(JMessageProtocolT::kMessageReady)) { ReceiveRecord(); } else if (sender == itsDataLink && message.Is(JAsynchDataReceiverT::kDataReady)) { ReceiveData(message); } else if (sender == itsProcess && message.Is(JProcess::kFinished)) { const JProcess::Finished* info = dynamic_cast<const JProcess::Finished*>(&message); assert( info != NULL ); const JBoolean stayOpen = ProcessFinished(*info); // let somebody else start a new process itsClearWhenStartFlag = kJFalse; // in case they call SetConnection() in ReceiveWithFeedback() Finished msg(info->Successful(), JI2B(info->GetReason() != kJChildFinished)); BroadcastWithFeedback(&msg); itsClearWhenStartFlag = JI2B(itsUseCount == 0 && !msg.SomebodyIsWaiting()); if (itsUseCount == 0 && !stayOpen && !ProcessRunning()) { Close(); } } else if (sender == itsPauseButton && message.Is(JXButton::kPushed)) { ToggleProcessRunning(); } else if (sender == itsStopButton && message.Is(JXButton::kPushed)) { StopProcess(); } else if (sender == itsKillButton && message.Is(JXButton::kPushed)) { KillProcess(); } else if (sender == itsEOFButton && message.Is(JXButton::kPushed)) { if (!(itsCmdInput->GetText()).IsEmpty()) { itsCmdInput->HandleKeyPress(kJReturnKey, JXKeyModifiers(GetDisplay())); } CloseOutFD(); UpdateButtons(); } else { CBTextDocument::Receive(sender, message); } }
void CBExecOutputDocument::SetConnection ( JProcess* p, const int inFD, const int outFD, const JCharacter* windowTitle, const JCharacter* dontCloseMsg, const JCharacter* execDir, const JCharacter* execCmd, const JBoolean showPID ) { assert( !ProcessRunning() && itsRecordLink == NULL && itsDataLink == NULL ); itsProcess = p; ListenTo(itsProcess); if (NeedsFormattedData()) { itsRecordLink = new RecordLink(inFD); assert( itsRecordLink != NULL ); ListenTo(itsRecordLink); } else { itsDataLink = new DataLink(inFD); assert( itsDataLink != NULL ); ListenTo(itsDataLink); } if (outFD != ACE_INVALID_HANDLE) { itsCmdStream = jnew JOutPipeStream(outFD, kJTrue); assert( itsCmdStream != NULL ); } CBTextEditor* te = GetTextEditor(); if (itsClearWhenStartFlag) { te->SetText(""); } else if (!te->IsEmpty()) { const JString& text = te->GetText(); JIndex i = text.GetLength()+1; while (i > 1 && text.GetCharacter(i-1) == '\n') { i--; } if (text.IndexValid(i)) { te->SetSelection(i, text.GetLength()); } te->Paste("\n\n----------\n\n"); te->ClearUndo(); } if (execCmd != NULL) { const JString timeStamp = JGetTimeStamp(); te->Paste(timeStamp); te->Paste("\n"); te->Paste(execDir); te->Paste("\n"); te->Paste(execCmd); if (showPID) { te->Paste("\n"); te->Paste(JGetString("ProcessID::CBExecOutputDocument")); te->Paste(JString(p->GetPID(), JString::kBase10)); } te->Paste("\n\n"); te->ClearUndo(); } itsPath = execDir; itsReceivedDataFlag = kJFalse; itsProcessPausedFlag = kJFalse; itsDontCloseMsg = dontCloseMsg; FileChanged(windowTitle, kJFalse); UpdateButtons(); te->SetWritable(kJFalse); itsCmdInput->SetText(""); }