void VPAbstractNode::renderSlotName(QPainter* painter) { int slotSize = VPAbstractNode::SlotSize; QFontMetricsF fontMetrics(gSlotFont); painter->setPen(Qt::black); painter->setFont(gSlotFont); for (int i(0); i<myInCount; i++) { // get slot offset QPointF namePos = inputSlots[i]->offset(); namePos.rx() += slotSize; namePos.ry() += slotSize*0.5; painter->drawText( namePos, QString( getProcess()->slot_name(true, i) ) ); } for (int i(0); i<myOutCount; i++) { const char* name = getProcess()->slot_name(false, i); QPointF namePos = outputSlots[i]->offset(); namePos.rx() -= (slotSize*1.5 + fontMetrics.width(name)); namePos.ry() += 0.5*slotSize; painter->drawText( namePos, QString(name) ); } }
void KGpgVerify::finish() { // GnuPG will return error code 2 if it wasn't able to verify the file. // If it complained about a missing signature before that is fine. if (((getProcess()->exitCode() == 2) && (getSuccess() == TS_MISSING_KEY)) || ((getProcess()->exitCode() == 1) && (getSuccess() == TS_BAD_SIGNATURE))) return; KGpgTextOrFileTransaction::finish(); }
////////////////////////////////////////////////////////////////////////// // 1,根据结点名字和端口名字(对于Processor)调整myRect的宽度 // 2,根据输入、输出端口的个数调整myRect的高度 ////////////////////////////////////////////////////////////////////////// // Note: // 1, this function is called in VPAbstractNode constructor and // VPTerminal::setupProcess // 2, this function may change the myRect, so it must be called after // VPAbstractNode::setupSlots ////////////////////////////////////////////////////////////////////////// void VPAbstractNode::adjustRectByContent() { //! [Adjust myRect width] QFontMetricsF headFontMetrics( font() ); //! [compute the head text width] qreal headTextWid = headFontMetrics.width( text() ); //! [compute the head text width] //! [compute the slot text width] int slotSize = VPAbstractNode::SlotSize; QFontMetricsF slotFontMetrics(gSlotFont); qreal inSlotMaxW = 0; for (int i(0); i<myInCount; i++) { qreal slotW = slotFontMetrics.width( QString(getProcess()->slot_name(true, i)) ); if ( slotW > inSlotMaxW ) inSlotMaxW = slotW; } int outSlotMaxW = 0; for (int i(0); i<myOutCount; i++) { qreal slotW = slotFontMetrics.width( QString(getProcess()->slot_name(false, i)) ); if ( slotW > outSlotMaxW ) outSlotMaxW = slotW; } //! [compute the slot text width] qreal maxW = (inSlotMaxW+outSlotMaxW)>headTextWid ? (inSlotMaxW+outSlotMaxW) : headTextWid; if (myRect.width() < maxW) myRect.adjust(0,0, maxW-myRect.width(), 0); //! [Adjust myRect width] //! [Adjust myRect height] //According to slot size, adjust the node height int maxCount = myInCount>myOutCount ? myInCount : myOutCount; int adjustHeight(0); if (maxCount-3>0) { int deltaY = myRect.height()*3/16; //估计值 //deltaY = 30; adjustHeight = (maxCount-3) * deltaY; myRect.adjust(0, 0, 0, adjustHeight); } //! [Adjust myRect height] }
void AgentThread::processCMDSTOP_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing CMDSTOP_REQUEST\n"); // read the serialized TestObject which we will stop TestObject test; test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // find the exit code, blocking for requested timeout if neccesary int wasRunning = FALSE; int status; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr==NULL) { printf("Error: Null process found on process list"); return; } if (curr->getTestID().compare(test.getTestID())==0) { ConsoleServer::debugMsg(5,"Stopping process\n"); wasRunning = TRUE; status = getProcess(i)->checkExitValue(); // flush and close it's output streams getProcess(i)->interrupt(); Utils::sendSignal(socketHandle,status); break; } } if (!wasRunning) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was not running :%s\n",test.getTestID().c_str()); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing CMDSTOP_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
virtual void _Reply_data(std::shared_ptr<protocol::Invoke> invoke) override final { if (invoke->has("_History_uid") == true) { // REGISTER THIS PROCESS ON HISTORY LIST std::shared_ptr<slave::InvokeHistory> history(new slave::InvokeHistory(invoke)); progress_list_.insert({ history->getUID(), history }); if (invoke->has("_Piece_first") == true) { // PARALLEL PROCESS size_t first = invoke->get("_Piece_first")->getValue<size_t>(); size_t last = invoke->get("_Piece_last")->getValue<size_t>(); invoke->erase(invoke->end() - 2, invoke->end()); ((base::ParallelSystemArrayBase*)system_array_)->sendPieceData(invoke, first, last); } else if (invoke->has("_Process_name") == true) { // DISTRIBUTED PROCESS auto ds_system_array = (distributed::base::DistributedSystemArrayBase*)system_array_; // FIND THE MATCHED ROLE const std::string &process_name = invoke->get("_Process_name")->getValue<std::string>(); if (ds_system_array->hasProcess(process_name) == false) return; // SEND DATA VIA THE ROLE auto process = ds_system_array->getProcess(process_name); ((distributed::base::DistributedProcessBase*)(process.get()))->sendData(invoke, 1.0); } } else replyData(invoke); };
void MemoryManager::showAllocatedMemory() { unsigned int beginAllocatedAddress, endAllocatedAddress, totalAllocated, processId, internalFragmentation, externalFragmentation; // INSERT YOUR CODE TO SHOW EACH ONE OF THE ALLOCATED MEMORY PARTITIONS, INCLUDING INTERNAL AND EXTERNAL (THE FOLLOWING) FRAGMENTATION auto freeIt = _freeList.begin(); for(auto it = _busyList.begin(); it != _busyList.end(); it++){ // for each partition... auto p = (*it); beginAllocatedAddress = p->getBeginAddress(); endAllocatedAddress = p->getEndAddress(); totalAllocated = p->getLength(); processId = p->getProcess()->getId(); internalFragmentation = 0; externalFragmentation = 0; // Como as listas estão ordenadas por endereço, // só é preciso verificar a _freeList em ordem if(p->getBeginAddress() > (*freeIt)->getEndAddress()) freeIt++; if((*freeIt)->getBeginAddress() == p->getEndAddress()+1) externalFragmentation = (*freeIt)->getLength(); // no not change the next line (the way information are shown) std::cout << "\tAllocd: " << "B=" << (beginAllocatedAddress) << ", \tE=" << (endAllocatedAddress) << ", \tT=" << (totalAllocated) << ", \tPID=" << (processId) << ", \tIF=" << (internalFragmentation) << ", \tEF=" << (externalFragmentation) << "\n"; } }
/** process_exit : 'process -> int <doc> Wait until the process terminate, then returns its exit code. </doc> **/ int _hx_std_process_exit( Dynamic handle ) { vprocess *p = getProcess(handle); hx::EnterGCFreeZone(); #ifdef NEKO_WINDOWS { DWORD rval; WaitForSingleObject(p->pinf.hProcess,INFINITE); hx::ExitGCFreeZone(); if( !GetExitCodeProcess(p->pinf.hProcess,&rval) ) return 0; return rval; } #else int rval=0; while( waitpid(p->pid,&rval,0) != p->pid ) { if( errno == EINTR ) continue; hx::ExitGCFreeZone(); return 0; } hx::ExitGCFreeZone(); if( !WIFEXITED(rval) ) return 0; return WEXITSTATUS(rval); #endif }
static int trylock() { h = NULL; posptr = faceptr = topptr = NULL; DWORD pid=getProcess(L"BF2142.exe"); if (!pid) return false; BYTE *mod=getModuleAddr(pid, L"BF2142Audio.dll"); if (!mod) return false; h=OpenProcess(PROCESS_VM_READ, false, pid); if (!h) return false; BYTE *cacheaddr = mod + 0x4745c; BYTE *cache = peekProcPtr(cacheaddr); posptr = peekProcPtr(cache + 0xc0); faceptr = peekProcPtr(cache + 0xc4); topptr = peekProcPtr(cache + 0xc8); float apos[3], afront[3], atop[3], cpos[3], cfront[3], ctop[3]; std::string context; std::wstring identity; if (fetch(apos, afront, atop, cpos, cfront, ctop, context, identity)) return true; CloseHandle(h); h = NULL; return false; }
bool Control::processStop(int process_nbr) { strstream strm; Process* process = getProcess(process_nbr); if (process == NULL) { strm << "Process: " << process_nbr << " not reachable!" << ends; theUI->showMsg(strm.str()); return false; } ProcessId pid = process->getProcessId(); const char* nm = process->getName(); if ( nm == NULL || nm[0] == '\0' ) { strm << "Process: " << process_nbr << " (PID " << pid << ") being stopped!" << ends; } else { strm << "Process: " << process_nbr << " (" << nm << ") being stopped!" << ends; } theUI->showMsg(strm.str()); bool stopped = process->stop(); if (stopped) { processTable->erase(process_nbr); return true; } return false; }
int process_tcp (u_char * userdata, const dp_header * header, const u_char * m_packet) { struct dpargs * args = (struct dpargs *) userdata; struct tcphdr * tcp = (struct tcphdr *) m_packet; curtime = header->ts; /* get info from userdata, then call getPacket */ Packet * packet; switch (args->sa_family) { case (AF_INET): packet = new Packet (args->ip_src, ntohs(tcp->source), args->ip_dst, ntohs(tcp->dest), header->len, header->ts); break; case (AF_INET6): packet = new Packet (args->ip6_src, ntohs(tcp->source), args->ip6_dst, ntohs(tcp->dest), header->len, header->ts); break; } Connection * connection = findConnection(packet); if (connection != NULL) { /* add packet to the connection */ connection->add(packet); } else { /* else: unknown connection, create new */ connection = new Connection (packet); getProcess(connection, args->device); } delete packet; /* we're done now. */ return true; }
STDMETHODIMP GuestProcessOutputEventWrap::COMGETTER(Process)(IGuestProcess **aProcess) { LogRelFlow(("{%p} %s: enter aProcess=%p\n", this, "GuestProcessOutputEvent::getProcess", aProcess)); VirtualBoxBase::clearError(); HRESULT hrc; try { CheckComArgOutPointerValidThrow(aProcess); AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) throw autoCaller.rc(); hrc = getProcess(ComTypeOutConverter<IGuestProcess>(aProcess).ptr()); } catch (HRESULT hrc2) { hrc = hrc2; } catch (...) { hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS); } LogRelFlow(("{%p} %s: leave *aProcess=%p hrc=%Rhrc\n", this, "GuestProcessOutputEvent::getProcess", *aProcess, hrc)); return hrc; }
bool Control::processStart(Process* process) { strstream strm; int process_nbr = process->ID(); (*processTable)[process_nbr] = process; if ( NULL == getProcess(process_nbr) ) { strm << "Process: " << process_nbr << " NOT started!" << ends; theUI->showMsg(strm.str()); return false; } bool success = process->start(); ProcessId pid = process->getProcessId(); if (success) { //strm << "Process: " << process_nbr << " (PID " << pid << ") started!" << ends; //theUI->showMsg(strm.str()); return true; } else { processTable->erase(process_nbr); strm << "Process: " << process_nbr << " (PID " << pid << ") NOT started and is removed!" << ends; theUI->showMsg(strm.str()); return false; } return false; }
static int trylock() { h = NULL; posptr = rotptr = NULL; DWORD pid=getProcess(L"left4dead.exe"); if (!pid) return false; BYTE *mod=getModuleAddr(pid, L"client.dll"); if (!mod) return false; h=OpenProcess(PROCESS_VM_READ, false, pid); if (!h) return false; posptr = mod + 0x580588; rotptr = mod + 0x4FF024; stateptr = mod + 0x4F8E34; float pos[3]; float rot[3]; float opos[3], top[3], front[3]; bool ok = peekProc(posptr, pos, 12) && peekProc(rotptr, rot, 12); if (ok) return calcout(pos, rot, opos, top, front); CloseHandle(h); h = NULL; return false; }
void AgentThread::processDAEMONCLEAN_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing DAEMONCLEAN_REQUEST\n"); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); //clean the files now for (int i = getProcessCount()-1; i >=0; i--) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (getProcess(i)->isDaemon()) { ConsoleServer::debugMsg(1,"Cleaning daemon %d\n",i); // clean up the trace files ConsoleServer::debugMsg(1, "Cleaning environment file :%s\n", curr->getEnvFileName().c_str()); if (Utils::delete_file(curr->getEnvFileName())!=0) ConsoleServer::debugMsg(1,"No environment file was found :%s\n", curr->getEnvFileName().c_str()); ConsoleServer::debugMsg(1,"Cleaning stdout file :%s\n", curr->getStdOutFileName().c_str()); if (Utils::delete_file(curr->getStdOutFileName())!=0) ConsoleServer::debugMsg(1,"No stdout file was found :%s\n", curr->getStdOutFileName().c_str()); ConsoleServer::debugMsg(1,"Cleaning stderr file :%s\n", curr->getStdErrFileName().c_str()); if (Utils::delete_file(curr->getStdErrFileName())!=0) ConsoleServer::debugMsg(1,"No stderr file was found :%s\n", curr->getStdErrFileName().c_str()); // remove from our list of test objects ConsoleServer::debugMsg(1,"Removing process from process pool\n"); delProcess(i); } } // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing DAEMONCLEAN_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } };
/// Basic Process Information: priority boost long System::pagefileUsageLimit(MemoryUnit unit, InfoType fetch, long pid) { POOLED_USAGE_AND_LIMITS quota; if ( fetch != NoFetch && getProcess()->query(pid, fetch, "a) ) { if ( long(quota.PagefileLimit) < 0 ) return -1;//LONG_MAX; return adjustMemory(unit, quota.PagefileLimit); } return -2; }
/// System Process Limits: Maximum amount of the page file this process is allowed to use long System::virtualMemoryLimit(MemoryUnit unit, InfoType fetch, long pid) { QUOTA_LIMITS quota; if ( fetch != NoFetch && getProcess()->query(pid, fetch, "a) ) { if ( long(quota.PagefileLimit) == -1 ) return -1;//LONG_MAX; return adjustMemory(unit, quota.PagefileLimit); } return 0; }
KGpgEncrypt::KGpgEncrypt(QObject *parent, const QStringList &userIds, const QList<QUrl> &files, const EncryptOptions &options, const QStringList &extraOptions) : KGpgTextOrFileTransaction(parent, files), m_fileIndex(0), m_options(options), m_userIds(userIds), m_extraOptions(extraOptions) { if ((m_options & AllowUntrustedEncryption) && !m_userIds.isEmpty()) m_extraOptions << trustOptions(getProcess()->program().at(0)); }
/** process_pid : 'process -> int <doc> Returns the process id. </doc> **/ int _hx_std_process_pid( Dynamic handle ) { vprocess *p = getProcess(handle); #ifdef NEKO_WINDOWS return p->pinf.dwProcessId; #else return p->pid; #endif }
bool KGpgSignText::nextLine(const QString &line) { if (line.startsWith(QLatin1String("[GNUPG:] BEGIN_SIGNING")) &! m_text.isEmpty()) { GPGProc *proc = getProcess(); proc->write(m_text.toUtf8()); proc->closeWriteChannel(); } else if (!line.startsWith(QLatin1String("[GNUPG:] SIGEXPIRED")) && !line.startsWith(QLatin1String("[GNUPG:] KEYEXPIRED "))) m_messages.append(line); return false; }
DGLDebugeeQTProcess::DGLDebugeeQTProcess(int port, bool modeEGL) : m_Port(port), m_Loaded(false), m_ModeEGL(modeEGL), m_PortStr(boost::lexical_cast<std::string>(getPort())), m_SemLoaderStr("sem_loader_" + m_PortStr), m_SemOpenGLStr("sem_" + m_PortStr), m_SemLoader(boost::interprocess::open_or_create, m_SemLoaderStr.c_str(), 0), m_SemOpenGL(boost::interprocess::open_or_create, m_SemOpenGLStr.c_str(), 0), m_PollTimer(new QTimer(this)) { CONNASSERT(m_PollTimer, SIGNAL(timeout()), this, SLOT(pollReady())); CONNASSERT(getProcess(), SIGNAL(started()), this, SLOT(startPolling())); CONNASSERT(getProcess(), SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleProcessError(QProcess::ProcessError))); CONNASSERT(getProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(handleProcessFinished(int, QProcess::ExitStatus))); }
void AgentThread::processCMDSTATUS_REQUEST(int socketHandle) { TestObject test; try { ConsoleServer::debugMsg(1,"Processing CMDSTATUS_REQUEST\n"); // read the serialized TestObject which we will stop test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); // find the exit code, blocking if neccesary int wasRunning = FALSE; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr->getTestID().compare(test.getTestID())==0) { ConsoleServer::debugMsg(8,"Found started process :%s\n",test.getTestID().c_str()); int status = getProcess(i)->getExitValue(); ConsoleServer::debugMsg(5,"Returning CMDSTATUS value :%d\n",status); Utils::writeInt(socketHandle,status); wasRunning = TRUE; break; } } if (!wasRunning) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str()); Utils::writeInt(socketHandle,FAILED); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char * message) { ConsoleServer::debugMsg(1,"Error processing CMDSTATUS_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } }
QString VPAbstractNode::getNodeTips(const QPointF& localPos) { SlotInfoType info = querySlot(localPos); int idx = info.second; if (-1==idx) return text(); //wrong return QString( getProcess()->slot_type(info.first, idx) ); }
bool Control::processExists(int process_nbr) { strstream strm; Process* process = getProcess(process_nbr); if (process == NULL || !process->exists() ) { return false; } return true; }
WallConfiguration::WallConfiguration(const Configuration& config, const uint processIndex_) : Process(getProcess(config, processIndex_)) , processIndex{processIndex_} , surfaces{config.surfaces} { processCountForHost = std::count_if(config.processes.begin(), config.processes.end(), [& host = host](const auto& p) { return p.host == host; }); }
/** process_stdin_close : 'process -> void <doc> Close the process standard input. </doc> **/ void _hx_std_process_stdin_close( Dynamic handle ) { vprocess *p = getProcess(handle); #ifdef NEKO_WINDOWS if ( p->iwrite ) CloseHandle(p->iwrite); #else if( p->iwrite!=-1 ) do_close(p->iwrite); #endif p->iwrite = HANDLE_INIT; }
//Funcao que coloca em foreground um job que foi pausado por ctrlz void fg(int jid) { Process_Object *p = getProcess(jid); if (p) { if (!p->lancado) { fgProcess = p; kill(p->pgid,SIGCONT); p->lancado = 1; waitProcess(p); } else perror("Job não esta rodando.\n"); } else perror("Job nao encontrada.\n"); }
// Whether or not the SipxProcessResource is ready for use by a SipxProcess. bool SipxProcessResource::isReadyToStart(UtlString& missingResource) { SipxProcess* myProcess = getProcess(); bool bReady = (myProcess && myProcess->isRunning()); if ( !bReady ) { missingResource = ""; appendDescription(missingResource); OsSysLog::add(FAC_SUPERVISOR, PRI_WARNING, "SipxProcessResource::isReadyToStart returns false; %s is not running ", data()); } return bReady; }
void KGpgExport::procSetup(const QStringList &options, const bool secret) { getProcess()->resetProcess(); if (secret) addArgument(QLatin1String( "--export-secret-key" )); else addArgument(QLatin1String( "--export" )); if ((m_outputmode == 2) && !options.contains(QLatin1String( "--armor" ))) addArgument(QLatin1String( "--armor" )); addArguments(options); }
void CompleteIOEvent::processEvent() { Process *process = getProcess(); process->removeBurst(); sim->dequeueIO(); sim->setIOFree(); cout << header() << " completes I/O burst."; if(process->hasMoreBursts()) { sim->waitForCPU(process); cout << " Queueing for CPU." << endl; } else { cout << endl; sim->addExitEvent(process); } sim->scheduleWaitingForCPU(); sim->scheduleWaitingForIO(); }// CompleteIOEvent::processEvent
void AgentThread::processGETTRACEPATHS_REQUEST(int socketHandle) { try { ConsoleServer::debugMsg(1,"Processing GETTRACEPATHS_REQUEST\n"); // read the serialized TestObject which we want the exit code of TestObject test; test.readTestObject(socketHandle); // now send a signal indicating we are processing the request Utils::sendSignal(socketHandle,RESPONSE_PROCESSING); int wasRun = FALSE; for (int i = 0; i < getProcessCount(); i++) { // check for any instance of test running with the same id TestObject *curr = getProcess(i)->getTestObject(); if (curr->getTestID().compare(test.getTestID())==0) { wasRun = true; Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); ConsoleServer::debugMsg(9,"Sending trace file paths\n"); ConsoleServer::debugMsg(9,"Env file :%s\n",curr->getEnvFileName().c_str()); ConsoleServer::debugMsg(9,"StdOut file :%s\n",curr->getStdOutFileName().c_str()); ConsoleServer::debugMsg(9,"StdErr file :%s\n",curr->getStdErrFileName().c_str()); // ---- send the env, stdout and stderr files -------------------- Utils::writeString(socketHandle,curr->getEnvFileName()); Utils::writeString(socketHandle,curr->getStdOutFileName()); Utils::writeString(socketHandle,curr->getStdErrFileName()); // ---------------------------------- break; } } if (!wasRun) { // the process was never started, so assume it failed ConsoleServer::debugMsg(1,"Process was never started :%s\n",test.getTestID().c_str()); Utils::writeInt(socketHandle,RESPONSE_FINISHED_ERROR); } else { // now send a signal indicating we have finished Utils::sendSignal(socketHandle,RESPONSE_FINISHED_OK); } } catch (char *message) { ConsoleServer::debugMsg(1,"Error processing GETTRACEPATHS_REQUEST request:%s\n",message); Utils::sendSignal(socketHandle,RESPONSE_FINISHED_ERROR); } }