Exemplo n.º 1
0
ProcessProperties ProcessInfo::GetProcessProperties(DWORD uid) const
{
	auto it = m_processProperties.find(uid);
	assert(it != m_processProperties.end());
	if (it == m_processProperties.end())
		return ProcessProperties(InternalProcessProperties());

	return ProcessProperties(it->second);
}
Exemplo n.º 2
0
    /**
     * Creates initial process tree
     */
    void ProcessManagerMac::createProcTree() {
        boost::recursive_mutex::scoped_lock lock( m_accessMutex );

        std::vector< kinfo_proc > procList;
        GetUnixProcesses( procList );

        _dbg("Mac Process count: %u!", procList.size());

        vector< kinfo_proc >::iterator it;
        vector< kinfo_proc >::iterator end_it = procList.end();

        // Creates a map with all processes that will be feed to m_processTree
        ProcessMap processMap;
        for ( it = procList.begin(); it != end_it; ++it ) {
            try {
                // Get the instantly available data
                pid_t pid = it->kp_proc.p_pid;
                pid_t ppid = it->kp_eproc.e_ppid;

                processMap[ pid ] = ProcessProperties();
                setProcessProperties( processMap[ pid ], pid, true, ppid, false, "" );
            } catch ( const std::exception & ex ) {
                _dbg("Exception while adding processes: %s", ex.what());
            }
        }

        boost::recursive_mutex::scoped_lock lock2( m_processTree.mutex() );
        m_processTree.clear();
        m_processTree.addConnectProcesses( processMap );

        //dumpTree();
    }
Exemplo n.º 3
0
static PP_Bool Instance_DidCreate(PP_Instance instance,
                                  uint32_t argc,
                                  const char* argn[],
                                  const char* argv[]) {
  g_ps_instance = instance;
  g_ps_main_cb = PSUserMainGet();
  s_verbosity = PSV_LOG;
  PSInterfaceInputEvent()->RequestInputEvents(
      g_ps_instance, PP_INPUTEVENT_CLASS_MOUSE | PP_INPUTEVENT_CLASS_KEYBOARD |
                      PP_INPUTEVENT_CLASS_WHEEL | PP_INPUTEVENT_CLASS_TOUCH);

  uint32_t i;
  struct StartInfo* si = malloc(sizeof(struct StartInfo));

  si->argc_ = 0;
  si->argv_ = calloc(argc + 1, sizeof(char*));
  si->argv_[0] = NULL;

  /* Process embed attributes into the environment.
   * Convert the attribute names to uppercase as environment variables are case
   * sensitive but are almost universally uppercase in practice. */
  for (i = 0; i < argc; i++) {
    char* key = strdup(argn[i]);
    char* c = key;
    while (*c) {
      *c = toupper((int)*c);
      ++c;
    }
    setenv(key, argv[i], 1);
    free(key);
  }

  /* Set a default value for SRC. */
  setenv("SRC", "NMF?", 0);
  /* Use the src tag name if ARG0 is not explicitly specified. */
  setenv("ARG0", getenv("SRC"), 0);

  /* Walk ARG0..ARGn populating argv until an argument is missing. */
  for (;;) {
    char arg_name[32];
    snprintf(arg_name, 32, "ARG%d", si->argc_);
    const char* next_arg = getenv(arg_name);
    if (NULL == next_arg)
      break;

    si->argv_[si->argc_++] = strdup(next_arg);
  }

  int props_processed = ProcessProperties();

  /* Log arg values only once ProcessProperties has been called so that the
   * PS_VERBOSITY attribute will be in effect. */
  for (i = 0; i < argc; i++) {
    if (argv[i]) {
      PSInstanceTrace("attribs[%d] '%s=%s'\n", i, argn[i], argv[i]);
    } else {
      PSInstanceTrace("attribs[%d] '%s'\n", i, argn[i]);
    }
  }

  for (i = 0; i < si->argc_; i++) {
    PSInstanceTrace("argv[%d] '%s'\n", i, si->argv_[i]);
  }

  if (!props_processed) {
    PSInstanceWarn("Skipping create thread.\n");
    return PP_FALSE;
  }

  pthread_t main_thread;
  int ret = pthread_create(&main_thread, NULL, MainThread, si);
  PSInstanceTrace("Created thread: %d.\n", ret);
  return ret == 0 ? PP_TRUE : PP_FALSE;
}