示例#1
0
/*
 * This function starts a request returned by init functions such as
 * MPI_Send_init(), MPI_Ssend_init (see above), and friends.
 * They should already have performed sanity checks.
 */
int PMPI_Start(MPI_Request * request)
{
  int retval = 0;

  smpi_bench_end();
  if (request == nullptr || *request == MPI_REQUEST_NULL) {
    retval = MPI_ERR_REQUEST;
  } else {
    MPI_Request req = *request;
    int my_proc_id = (req->comm() != MPI_COMM_NULL) ? simgrid::s4u::this_actor::get_pid() : -1;
    TRACE_smpi_comm_in(my_proc_id, __func__,
                       new simgrid::instr::Pt2PtTIData("Start", req->dst(),
                                                       req->size(),
                                                       req->tag(), 
                                                       simgrid::smpi::Datatype::encode(req->type())));
    if (not TRACE_smpi_view_internals() && req->flags() & MPI_REQ_SEND)
      TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());

    req->start();

    if (not TRACE_smpi_view_internals() && req->flags() & MPI_REQ_RECV)
      TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
    retval = MPI_SUCCESS;
    TRACE_smpi_comm_out(my_proc_id);
  }
  smpi_bench_begin();
  return retval;
}
示例#2
0
int PMPI_Sendrecv(const void* sendbuf, int sendcount, MPI_Datatype sendtype, int dst, int sendtag, void* recvbuf,
                  int recvcount, MPI_Datatype recvtype, int src, int recvtag, MPI_Comm comm, MPI_Status* status)
{
  int retval = 0;

  smpi_bench_end();

  if (comm == MPI_COMM_NULL) {
    retval = MPI_ERR_COMM;
  } else if (not sendtype->is_valid() || not recvtype->is_valid()) {
    retval = MPI_ERR_TYPE;
  } else if (src == MPI_PROC_NULL) {
    if(status!=MPI_STATUS_IGNORE){
      simgrid::smpi::Status::empty(status);
      status->MPI_SOURCE = MPI_PROC_NULL;
    }
    if(dst != MPI_PROC_NULL)
      simgrid::smpi::Request::send(sendbuf, sendcount, sendtype, dst, sendtag, comm);
    retval = MPI_SUCCESS;
  }else if (dst == MPI_PROC_NULL){
    simgrid::smpi::Request::recv(recvbuf, recvcount, recvtype, src, recvtag, comm, status);
    retval = MPI_SUCCESS;
  }else if (dst >= comm->group()->size() || dst <0 ||
      (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0))){
    retval = MPI_ERR_RANK;
  } else if ((sendcount < 0 || recvcount<0) ||
      (sendbuf==nullptr && sendcount > 0) || (recvbuf==nullptr && recvcount>0)) {
    retval = MPI_ERR_COUNT;
  } else if((sendtag<0 && sendtag !=  MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){
    retval = MPI_ERR_TAG;
  } else {
    int my_proc_id         = simgrid::s4u::this_actor::get_pid();
    int dst_traced         = getPid(comm, dst);
    int src_traced         = getPid(comm, src);

    // FIXME: Hack the way to trace this one
    std::vector<int>* dst_hack = new std::vector<int>;
    std::vector<int>* src_hack = new std::vector<int>;
    dst_hack->push_back(dst_traced);
    src_hack->push_back(src_traced);
    TRACE_smpi_comm_in(my_proc_id, __func__,
                       new simgrid::instr::VarCollTIData(
                           "sendRecv", -1, sendtype->is_replayable() ? sendcount : sendcount * sendtype->size(),
                           dst_hack, recvtype->is_replayable() ? recvcount : recvcount * recvtype->size(), src_hack,
                           simgrid::smpi::Datatype::encode(sendtype), simgrid::smpi::Datatype::encode(recvtype)));

    TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, sendtag, sendcount * sendtype->size());

    simgrid::smpi::Request::sendrecv(sendbuf, sendcount, sendtype, dst, sendtag, recvbuf, recvcount, recvtype, src,
                                     recvtag, comm, status);
    retval = MPI_SUCCESS;

    TRACE_smpi_recv(src_traced, my_proc_id, recvtag);
    TRACE_smpi_comm_out(my_proc_id);
  }

  smpi_bench_begin();
  return retval;
}
示例#3
0
static PSPAMResult_t handleOpenRequest(char *msgBuf)
{
    char user[USERNAME_LEN], rhost[HOSTNAME_LEN];
    pid_t pid, sid;
    struct passwd *spasswd;
    User_t *pamUser;
    PSPAMResult_t res = PSPAM_RES_DENY;
    char *ptr = msgBuf;

    /* ensure we use the same byteorder as the PAM module */
    bool byteOrder = setByteOrder(true);

    /* get ssh pid */
    getPid(&ptr, &pid);
    /* get ssh sid */
    getPid(&ptr, &sid);
    /* get pam username */
    getString(&ptr, user, sizeof(user));
    /* get pam rhost */
    getString(&ptr, rhost, sizeof(rhost));

    /* reset psserial's byteorder */
    setByteOrder(byteOrder);

    mdbg(PSPAM_LOG_DEBUG, "%s: got pam request user: '******' pid: %i sid: %i"
	 " rhost: '%s'\n", __func__, user, pid, sid, rhost);

    errno = 0;
    spasswd = getpwnam(user);
    if (!spasswd && errno) mwarn(errno, "%s: getpwnam(%s)", __func__, user);

    pamUser = findUser(user, NULL);

    /* Determine user's allowance */
    if (spasswd && isPSAdminUser(spasswd->pw_uid, spasswd->pw_gid)) {
	res = PSPAM_RES_ADMIN_USER;
    } else if (pamUser) {
	if (pamUser->state == PSPAM_STATE_PROLOGUE) {
	    res = PSPAM_RES_PROLOG;
	} else {
	    res = PSPAM_RES_BATCH;
	    addSession(user, rhost, pid, sid);
	}
    }

    mdbg(PSPAM_LOG_DEBUG, "%s: reply to user '%s' rhost '%s': %i\n", __func__,
	 user, rhost, res);

    return res;
}
示例#4
0
// hunt down and kill processes that have files open on the given mount point
void Process::killProcessesWithOpenFiles(const char *path, int action) {
    DIR*    dir;
    struct dirent* de;

    if (!(dir = opendir("/proc"))) {
        SLOGE("opendir failed (%s)", strerror(errno));
        return;
    }
	LOGE("(%s) (%d)", path, action);

    while ((de = readdir(dir))) {
        int killed = 0;
        int pid = getPid(de->d_name);
        char name[PATH_MAX];

        if (pid == -1)
            continue;
        getProcessName(pid, name, sizeof(name));
        char openfile[PATH_MAX];

        if (checkFileDescriptorSymLinks(pid, path, openfile, sizeof(openfile))) {
            LOGE("Process %s (%d) has open file %s", name, pid, openfile);
			killed = 1;
        } else if (checkFileMaps(pid, path, openfile, sizeof(openfile))) {
            LOGE("Process %s (%d) has open filemap for %s", name, pid, openfile);
			killed = 1;
        } else if (checkSymLink(pid, path, "cwd")) {
            LOGE("Process %s (%d) has cwd within %s", name, pid, path);
			killed = 1;
        } else if (checkSymLink(pid, path, "root")) {
            LOGE("Process %s (%d) has chroot within %s", name, pid, path);
			killed = 1;
        } else if (checkSymLink(pid, path, "exe")) {
            LOGE("Process %s (%d) has executable path within %s", name, pid, path);
        } else {
//            continue;
        }
		
#if 1
		if( (!strcmp("android.process.media", name) && (strcmp("/mnt/extsd", path)) ) || killed == 1) {
			if (action == 1) {
				LOGE("Sending SIGHUP to process %d", pid);
				kill(pid, SIGTERM);
			} else if (action == 2) {
				LOGE("Sending SIGKILL to process %d", pid);
				kill(pid, SIGKILL);
			}
		}
#else		
        if (action == 1) {
            SLOGE("Sending SIGHUP to process %d", pid);
            kill(pid, SIGTERM);
        } else if (action == 2) {
            SLOGE("Sending SIGKILL to process %d", pid);
            kill(pid, SIGKILL);
        }
#endif
    }
    closedir(dir);
}
示例#5
0
// ----------------------------------------------------
// Function called when we want to stop the server.
// This code is called by the stop-ds.bat batch file to stop the server
// in windows.
// This function expects just one parameter to be passed
// to the executable: the directory of the server we want
// to stop.
//
// If the instance could be stopped the pid file
// is removed.  This is done for security reasons: if we do
// not delete the pid file and the old pid of the process
// is used by a new process, when we call again this executable
// the new process will be killed.
// Note: even if the code in the class org.opends.server.core.DirectoryServer
// sets the pid file to be deleted on the exit of the process
// the file is not always deleted.
//
// Returns 0 if the instance could be stopped using the
// pid stored in a file of the server installation and
// -1 otherwise.
// ----------------------------------------------------
int stop(const char* instanceDir)
{
  int returnCode = -1;

  int childPid;

  debug("Attempting to stop the server running at root '%s'.", instanceDir);

  childPid = getPid(instanceDir);

  if (childPid != 0)
  {
    if (killProcess(childPid))
    {
      returnCode = 0;
      deletePidFile(instanceDir);
    }
  }
  else
  {
    debug("Could not stop the server running at root '%s' because the pid could not be located.", instanceDir);
  }

  return returnCode;
} // stop
STDMETHODIMP GuestProcessOutputEventWrap::COMGETTER(Pid)(ULONG *aPid)
{
    LogRelFlow(("{%p} %s: enter aPid=%p\n", this, "GuestProcessOutputEvent::getPid", aPid));

    VirtualBoxBase::clearError();

    HRESULT hrc;

    try
    {
        CheckComArgOutPointerValidThrow(aPid);

        AutoCaller autoCaller(this);
        if (FAILED(autoCaller.rc()))
            throw autoCaller.rc();

        hrc = getPid(aPid);
    }
    catch (HRESULT hrc2)
    {
        hrc = hrc2;
    }
    catch (...)
    {
        hrc = VirtualBoxBase::handleUnexpectedExceptions(this, RT_SRC_POS);
    }

    LogRelFlow(("{%p} %s: leave *aPid=%RU32 hrc=%Rhrc\n", this, "GuestProcessOutputEvent::getPid", *aPid, hrc));
    return hrc;
}
示例#7
0
int codeVersionTable1_3::statusfld::dump(DumpContext& dc) { // throws IOException
    dc.indent();
    dc.getPs().print("statusfld\n");
    dc.increaseIndent();
    int retVal= 0;
    // write frequencyVector
    dc.indent();
    dc.getPs().print("frequencyVector=");
    dc.getPs().println((long)frequencyVector);
    // write modulationType
    dc.indent();
    dc.getPs().print("modulationType=");
    dc.getPs().println((long)modulationType);
    // write bf1
    {
        dc.indent();
        dc.getPs().print("reserved: ");
        dc.getPs().printlnBin(getReserved(),3);
        dc.indent();
        dc.getPs().print("pid: ");
        dc.getPs().printlnBin(getPid(),13);
    }
    dc.decreaseIndent();
    return retVal;
}
示例#8
0
 void router_init_script(char *arg)
{
	int pid=0;
	int i;
	char tmpBuf[MAX_MSG_BUFFER_SIZE]={0};

	snprintf(tmpBuf, MAX_MSG_BUFFER_SIZE, "%s/%s.pid", _DHCPD_PID_PATH, _DHCPD_PROG_NAME);
	pid = getPid(tmpBuf);
	if ( pid > 0) { 
		kill(pid, SIGUSR1);
	}

	usleep(1000);

	if (pid > 0) {
		system("killall -9 udhcpd 2> /dev/null");
		system("rm -f /var/run/udhcpd.pid 2> /dev/null");
	}
	killSomeDaemon();

	system("killsh.sh");	

	sprintf(tmpBuf, "%s gw %s", _CONFIG_SCRIPT_PROG, arg);
	for(i=3; i<sysconf(_SC_OPEN_MAX); i++)
	{
		close(i);
	}

	sleep(1);
	system(tmpBuf);
}
示例#9
0
int PMPI_Ssend(const void* buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) {
  int retval = 0;

  smpi_bench_end();

  if (comm == MPI_COMM_NULL) {
    retval = MPI_ERR_COMM;
  } else if (dst == MPI_PROC_NULL) {
    retval = MPI_SUCCESS;
  } else if (dst >= comm->group()->size() || dst <0){
    retval = MPI_ERR_RANK;
  } else if ((count < 0) || (buf==nullptr && count > 0)) {
    retval = MPI_ERR_COUNT;
  } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
    retval = MPI_ERR_TYPE;
  } else if(tag<0 && tag !=  MPI_ANY_TAG){
    retval = MPI_ERR_TAG;
  } else {
    int my_proc_id         = simgrid::s4u::this_actor::get_pid();
    int dst_traced         = getPid(comm, dst);
    TRACE_smpi_comm_in(my_proc_id, __func__,
                       new simgrid::instr::Pt2PtTIData("Ssend", dst,
                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                       tag, simgrid::smpi::Datatype::encode(datatype)));
    TRACE_smpi_send(my_proc_id, my_proc_id, dst_traced, tag, count * datatype->size());

    simgrid::smpi::Request::ssend(buf, count, datatype, dst, tag, comm);
    retval = MPI_SUCCESS;

    TRACE_smpi_comm_out(my_proc_id);
  }

  smpi_bench_begin();
  return retval;
}
示例#10
0
int main(void) {
    
    srand ( time(NULL) );
    //create a new PCB with priority between 0 - 15 and test getters
    printf ("Create PCB:\n");
    PCB_p PCBTest1 = create("PCB1", 1, rand()%15);
    printf ("Name: %s and Process ID: %d and Priority: %d\n", getName(PCBTest1), getPid(PCBTest1), getPriority(PCBTest1));
    // test toString() method
    printf("Test toString()\n");
    toString(PCBTest1); printf("\n");
    //free PCB
    printf ("Free PCB:\n");
    freePCB(PCBTest1);
    toString(PCBTest1); printf("\n");
    
    //test create PCB with wrong type for NAME --- EXECUTION FAILS
 //   PCB_p PCBTest2 = create(5, 1, 4);
 //   toString(PCBTest2); printf("\n");
    //test create PCB with wrong type PID   --- Creates PCB and RETURNS RANDOM VALUE
    PCB_p PCBTest3 = create("PCB3", "1", rand()%15);
    toString(PCBTest3); printf("\n");
    //test create PCB with non-int priority   
    PCB_p PCBTest4 = create("PCB4", 1, "c");
    toString(PCBTest4); printf("\n");
    //test create PCB with priority value > 15  
    PCB_p PCBTest5 = create("PCB5", 1, 16);
    toString(PCBTest5); printf("\n");
    //test create PCB with priority value < 0 
    PCB_p PCBTest6 = create("PCB6", 1, -1);
    toString(PCBTest6); printf("\n");
    

    
    return 0;
}
示例#11
0
void
showPomdpSolveParams( PomdpSolveParams params )
{
  ConfigFile cfg;

  fprintf( params->report_file,
		 " //****************\\\\\n" );
  fprintf( params->report_file,
		 "||   %s    ||\n", params->opts->__exec_name__ );
  fprintf( params->report_file,
		 "||     v. %s       ||\n", params->opts->__version__ );
  fprintf( params->report_file,
		 " \\\\****************//\n" );
  fprintf( params->report_file,
		 "      PID=%d\n", getPid() );

  cfg = POMDP_SOLVE_OPTS_toConfigFile( params->opts );

  fprintf( params->report_file,
		 "- - - - - - - - - - - - - - - - - - - -\n" );

  CF_fprintf( cfg, params->report_file );

  fprintf( params->report_file,
		 "- - - - - - - - - - - - - - - - - - - -\n" );

  CF_delete( cfg );


} /* showPomdpSolveParams */
示例#12
0
void MouseEventTool::getMainWindowNumber() {
    pid_t pid = getPid();

    if (windowNumber_ == NULL) {
        // Get the windowNumber of the main window
        CFArrayRef windows = CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
        for (int i = 0; i < CFArrayGetCount(windows); ++i) {
            CFDictionaryRef windInfo = (CFDictionaryRef) CFArrayGetValueAtIndex(windows, i);

            // We'll know if it's this process because it has the same PID as us, and it's got a name.
            int windowPid;
            CFNumberRef windowPidRef = (CFNumberRef) CFDictionaryGetValue(windInfo, kCGWindowOwnerPID);
            CFNumberGetValue(windowPidRef, kCFNumberIntType, &windowPid);
            if (windowPid == pid) {                CFStringRef windName;
                bool val = CFDictionaryGetValueIfPresent(windInfo, kCGWindowName, (const void**) &windName);
                if (val) {
                    // Store the window number so it's easier to do searches in the future.
                    CFNumberRef windNum = (CFNumberRef) CFDictionaryGetValue(windInfo, kCGWindowNumber);
                    windowNumber_ = windNum;
                    break;
                }
            }
        }
    }
}
示例#13
0
void
FGP_show( FiniteGridParams params ) 
{
  ConfigFile cfg;

  fprintf( params->report_file, 
		 " //****************\\\\\n" );
  fprintf( params->report_file, 
		 "||    %s      ||\n", params->opts->__exec_name__ );
  fprintf( params->report_file, 
		 "||     v. %s       ||\n", params->opts->__version__ );
  fprintf( params->report_file, 
		 " \\\\****************//\n" );
  fprintf( params->report_file, 
		 "      PID=%d\n", getPid() );

  cfg = POMDP_FG_OPTS_toConfigFile( params->opts );

  fprintf( params->report_file, 
		 "- - - - - - - - - - - - - - - - - - - -\n" );

  CF_fprintf( cfg, params->report_file );
 
  fprintf( params->report_file, 
		 "- - - - - - - - - - - - - - - - - - - -\n" );

  CF_delete( cfg );

} /* FGP_show */
示例#14
0
int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status)
{
  int retval = 0;

  smpi_bench_end();
  if (comm == MPI_COMM_NULL) {
    retval = MPI_ERR_COMM;
  } else if (src == MPI_PROC_NULL) {
    if(status != MPI_STATUS_IGNORE){
      simgrid::smpi::Status::empty(status);
      status->MPI_SOURCE = MPI_PROC_NULL;
    }
    retval = MPI_SUCCESS;
  } else if (src!=MPI_ANY_SOURCE && (src >= comm->group()->size() || src <0)){
    retval = MPI_ERR_RANK;
  } else if ((count < 0) || (buf==nullptr && count > 0)) {
    retval = MPI_ERR_COUNT;
  } else if (datatype==MPI_DATATYPE_NULL || not datatype->is_valid()) {
    retval = MPI_ERR_TYPE;
  } else if(tag<0 && tag !=  MPI_ANY_TAG){
    retval = MPI_ERR_TAG;
  } else {
    int my_proc_id = simgrid::s4u::this_actor::get_pid();
    TRACE_smpi_comm_in(my_proc_id, __func__,
                       new simgrid::instr::Pt2PtTIData("recv", src,
                                                       datatype->is_replayable() ? count : count * datatype->size(),
                                                       tag, simgrid::smpi::Datatype::encode(datatype)));

    simgrid::smpi::Request::recv(buf, count, datatype, src, tag, comm, status);
    retval = MPI_SUCCESS;

    // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
    int src_traced=0;
    if (status != MPI_STATUS_IGNORE) 
      src_traced = getPid(comm, status->MPI_SOURCE);
    else
      src_traced = getPid(comm, src);
    if (not TRACE_smpi_view_internals()) {
      TRACE_smpi_recv(src_traced, my_proc_id, tag);
    }
    
    TRACE_smpi_comm_out(my_proc_id);
  }

  smpi_bench_begin();
  return retval;
}
示例#15
0
void
FGP_doPostParseActions( FiniteGridParams params ) {
  /*
    Does more customized checking of the options to the program.
  */
  PomdpFgProgOptions opts;
  char tmp_str[MAX_OPT_STRING_LEN];
  int idx;

  /* just for convenience within this routine */
  opts = params->opts;

  /* Must have a POMDP filename or else things ill not work. */
  if (( opts->pomdp_filename == NULL )
	 || ( opts->pomdp_filename[0] == '\0' ))
    {
	 fprintf( stderr, "No POMDP file specified. Use '-h' for help.\n" );
	 exit( 1 );
    }

  /****************/
   /* First see if a random number seed is given, and if it is set the
      seed to this value. */
  if( opts->rand_seed[0] != '\0' )
    setRandomSeedFromString( opts->rand_seed );

  /* Otherwise initialize the random number generator with
	psuedo-random seed. */
  else
    randomize();

  /****************/
  /* Try to make the prefix be the prefix of the POMDP file if the
	default is chosen. */
  if ( strcmp( opts->prefix_str, POMDP_FG_OPTS_OPT_O_DEFAULT ) == 0 ) {

    strcpy( tmp_str, opts->pomdp_filename );

    /* This will point to null term at first */
    idx = strlen( tmp_str );  

    /* Start at the end and move left until we see the first
	  "period". */
    while (( idx > 0 ) && ( tmp_str[idx] != '.'))
	 idx--;

    /* Only override if we found a period in param filename */
    if ( idx > 0 ) {

	 /* Null terminate at the period */
	 tmp_str[idx] = '\0';

	 sprintf( opts->prefix_str, "%s-%d", tmp_str, getPid() );
	 
    } /* if we can override the default */

  } /* if default prefix is being used */

} /* FGP_doPostParseActions */
示例#16
0
bool gmshLocalNetworkClient::kill()
{
  // FIXME: we should kill all the clients in the list
  if(getPid() > 0) {
    if(KillProcess(getPid())){
      Msg::Info("Killed '%s' (pid %d)", _name.c_str(), getPid());
#if defined(HAVE_FLTK)
      if(FlGui::available())
        FlGui::instance()->setProgress("Killed", 0, 0, 0);
#endif
      setPid(-1);
      return true;
    }
  }
  setPid(-1);
  return false;
}
示例#17
0
bool Dynamic::isRunning()
{
    #if defined Q_OS_WIN
    return false;
    #else
    int pid=getPid();
    return pid ? 0==::kill(pid, 0) : false;
    #endif
}
示例#18
0
bool MPDUser::isRunning()
{
    #ifdef Q_OS_WIN
    return false;
    #else
    int pid=getPid();
    return pid ? 0==::kill(pid, 0) : false;
    #endif
}
示例#19
0
void cond_variable_wait(cond_variable * c, mutex * m)
{
	/* add thread to cond_variable queue */
	enque(c->q, getPid());
	/* sleep thread and release lock atomically */

	release_lock_and_sleep(m);
	/* re-aquire lock */
	mutex_lock(m);
}
示例#20
0
int sys_getpid(int *retval){
	pid_t pid;
	pid=getPid();
	*retval=(int)pid;
	//kprintf("\n in sys_getpid fun::%d",pid);
	/*if(syscall is successfull){
		return 0;
	}
	return -1; */
	return pid;
}
示例#21
0
文件: inject.c 项目: 2over12/crab
int main(int argc,char *argv[])
{	
	DWORD pid;
	pid=getPid("iexplore.exe");
	printf("%d\n",pid);
	DLLInject("box.dll",pid);
	printf("success\n");
	

	return 0;
}
示例#22
0
void Dynamic::stop(bool sendClear)
{
    if (isRemote()) {
        if (sendClear) {
            sendCommand(Control, QStringList() << "stop" << "1");
        } else {
            sendCommand(Control, QStringList() << "stop");
        }
        return;
    }

    #if !defined Q_OS_WIN
    int i=currentEntry.isEmpty() ? -1 : entryList.indexOf(currentEntry);
    QModelIndex idx=index(i, 0, QModelIndex());
    int pid=getPid();

    if (!pid) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(false);
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }

    if (0!=::kill(pid, 0)) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(false);
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }

    if (controlApp(false)) {
        if (sendClear) {
            emit clear();
        }
        currentEntry=QString();
        emit running(isRunning());
        if (idx.isValid()) {
            emit dataChanged(idx, idx);
        }
        return;
    }
    #endif
}
示例#23
0
文件: scheduler.cpp 项目: 8l/zsim
void Scheduler::waitUntilQueued(ThreadInfo* th) {
    uint64_t startNs = getNs();
    uint32_t sleepUs = 1;
    while(!IsSleepingInFutex(th->linuxPid, th->linuxTid, (uintptr_t)&schedLock)) {
        TrueSleep(sleepUs++); // linear backoff, start small but avoid overwhelming the OS with short sleeps
        uint64_t curNs = getNs();
        if (curNs - startNs > (2L<<31L) /* ~2s */) {
            warn("waitUntilQueued for pid %d tid %d timed out", getPid(th->gid), getTid(th->gid));
            return;
        }
    }
}
示例#24
0
int PMPI_Startall(int count, MPI_Request * requests)
{
  int retval;
  smpi_bench_end();
  if (requests == nullptr) {
    retval = MPI_ERR_ARG;
  } else {
    retval = MPI_SUCCESS;
    for (int i = 0; i < count; i++) {
      if(requests[i] == MPI_REQUEST_NULL) {
        retval = MPI_ERR_REQUEST;
      }
    }
    if(retval != MPI_ERR_REQUEST) {
      int my_proc_id = simgrid::s4u::this_actor::get_pid();
      TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Startall"));
      MPI_Request req = MPI_REQUEST_NULL;
      if (not TRACE_smpi_view_internals())
        for (int i = 0; i < count; i++) {
          req = requests[i];
          if (req->flags() & MPI_REQ_SEND)
            TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());
        }

      simgrid::smpi::Request::startall(count, requests);

      if (not TRACE_smpi_view_internals())
        for (int i = 0; i < count; i++) {
          req = requests[i];
          if (req->flags() & MPI_REQ_RECV)
            TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
        }
      TRACE_smpi_comm_out(my_proc_id);
    }
  }
  smpi_bench_begin();
  return retval;
}
示例#25
0
//  This seems redunant now with getProcessStatusAsString().
pdstring process::getProcessStatus() const 
{
   char ret[80];

   switch (status()) {
	case running:
	    sprintf(ret, "%d running", getPid());
	    break;
	case neonatal:
	    sprintf(ret, "%d neonatal", getPid());
	    break;
	case stopped:
	    sprintf(ret, "%d stopped", getPid());
	    break;
	case exited:
	    sprintf(ret, "%d exited", getPid());
	    break;
	default:
	    sprintf(ret, "%d UNKNOWN State", getPid());
	    break;
    }
    return(ret);
}
// hunt down and kill processes that have files open on the given mount point
void killProcessesWithOpenFiles(const char *path, int action)
{
    DIR *dir;
    struct dirent *de;

    if (!(dir = opendir("/proc"))) {
        SLOGE("opendir failed (%s)", strerror(errno));
        return;
    }

    while ((de = readdir(dir))) {
        int pid = getPid(de->d_name);
        char name[PATH_MAX];

        if (pid == -1)
            continue;
        getProcessName(pid, name, sizeof(name));

        char openfile[PATH_MAX];

        if (checkfileDescriptorSymLinks
                (pid, path, openfile, sizeof(openfile))) {
            SLOGE("Process %s (%d) has open file %s", name, pid,
                  openfile);
        } else if (checkfileMaps(pid, path, openfile, sizeof(openfile))) {
            SLOGE("Process %s (%d) has open filemap for %s", name,
                  pid, openfile);
        } else if (checkSymLink(pid, path, "cwd")) {
            SLOGE("Process %s (%d) has cwd within %s", name, pid,
                  path);
        } else if (checkSymLink(pid, path, "root")) {
            SLOGE("Process %s (%d) has chroot within %s", name, pid,
                  path);
        } else if (checkSymLink(pid, path, "exe")) {
            SLOGE("Process %s (%d) has executable path within %s",
                  name, pid, path);
        } else {
            continue;
        }
        if (action == 1) {
            SLOGW("Sending SIGHUP to process %d", pid);
            kill(pid, SIGTERM);
        } else if (action == 2) {
            SLOGE("Sending SIGKILL to process %d", pid);
            kill(pid, SIGKILL);
        }
    }
    closedir(dir);
}
示例#27
0
QVariant Sniffer::getField(uint32 index)
{
	switch(index)
	{
		case 0:
			return (isDead) ? QPixmap(":/Common/no.png") : QPixmap(":/Common/ok.png");
		case 1:
			return getPid();
		case 2:
			return _packetList->rowCount();
		case 3:
			return _processName;
	}
	return QVariant();
}
示例#28
0
static void handleCloseRequest(char *msgBuf)
{
    char user[USERNAME_LEN];
    char *ptr = msgBuf;
    pid_t pid;

    /* get ssh pid */
    getPid(&ptr, &pid);
    /* get pam username */
    getString(&ptr, user, sizeof(user));

    mdbg(PSPAM_LOG_DEBUG, "%s: got pam close of user: '******' pid: %i\n", __func__,
	 user, pid);
    rmSession(user, pid);
}
示例#29
0
int codeVersionTable1_3::statusfld2::dump(DumpContext& dc) { // throws IOException
    dc.indent();
    dc.getPs().print("statusfld2\n");
    dc.increaseIndent();
    int retVal= 0;
    // write mcAddress
    if ( mcAddress != NULL ) {
        dc.indent();
        dc.getPs().println("mcAddress") ;
        retVal +=mcAddress->dump(dc);
    }
    // write sourceIpAddress
    if ( sourceIpAddress != NULL ) {
        dc.indent();
        dc.getPs().println("sourceIpAddress") ;
        retVal +=sourceIpAddress->dump(dc);
    }
    // write destinationIpAddress
    if ( destinationIpAddress != NULL ) {
        dc.indent();
        dc.getPs().println("destinationIpAddress") ;
        retVal +=destinationIpAddress->dump(dc);
    }
    // write sourcePortNumber
    dc.indent();
    dc.getPs().print("sourcePortNumber=");
    dc.getPs().println((long)sourcePortNumber);
    // write destinatioPortNumber
    dc.indent();
    dc.getPs().print("destinatioPortNumber=");
    dc.getPs().println((long)destinatioPortNumber);
    // write applicationId
    dc.indent();
    dc.getPs().print("applicationId=");
    dc.getPs().println((long)applicationId);
    // write modulationType
    dc.indent();
    dc.getPs().print("modulationType=");
    dc.getPs().println((long)modulationType);
    // write bf2
    {
        dc.indent();
        dc.getPs().print("pid: ");
        dc.getPs().printlnBin(getPid(),13);
    }
    dc.decreaseIndent();
    return retVal;
}
示例#30
0
	void injector::injectDll(std::string processName, std::string dllLocation)
	{
		const char *dllLocationBuffer = dllLocation.c_str();
		size_t dllLocationLength = strlen(dllLocationBuffer);

		DWORD pid = getPid(processName);
		HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
		LPVOID loadLibraryAddress = (LPVOID) GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
		LPVOID loadLibraryArgument = (LPVOID) VirtualAllocEx(process, NULL, dllLocationLength, MEM_RESERVE | MEM_COMMIT,PAGE_READWRITE);
		int writeSuccess = WriteProcessMemory(process, loadLibraryArgument, dllLocationBuffer, dllLocationLength, NULL);
		HANDLE threadID = CreateRemoteThread(process, NULL, 0, (LPTHREAD_START_ROUTINE) loadLibraryAddress, loadLibraryArgument, NULL, NULL);

		isInjected_ = !containsNullVariable(process, loadLibraryAddress, loadLibraryArgument, writeSuccess, threadID);

		CloseHandle(process);
	}