Exemple #1
0
void
SimpleCpcClient::cmd_stop(char *arg) {
  Properties p;
  Vector<Process> proc_list;

  list_processes(proc_list, p);
  bool stopped = false;

  for(size_t i = 0; i < proc_list.size(); i++) {
    if(strcmp(proc_list[i].m_name.c_str(), arg) == 0) {
      stopped = true;
      Properties reply;
      stop_process(proc_list[i].m_id, reply);

      Uint32 status;
      reply.get("status", &status);
      if(status != 0) {
	BaseString msg;
	reply.get("errormessage", msg);
	ndbout << "Stop failed: " << msg << endl;
      }
    }
  }
  
  if(!stopped)
    ndbout << "No such process" << endl;
}
Exemple #2
0
void
SimpleCpcClient::cmd_list(char *arg) {
  Properties p;
  Vector<Process> proc_list;
  list_processes(proc_list, p);

  for(size_t i = 0; i < proc_list.size(); i++) {
    printproc(proc_list[i]);
  }
}
Exemple #3
0
int programs_running_count(const ustring & commandline)
// Returns how many times the program given on "commandline" is running.
{
  // Get the processes.
  vector <ustring> processes = list_processes ();
  // Usage count.
  int count = 0;
  for (unsigned int i = 0; i < processes.size(); i++)
    if (processes[i].find(commandline) != string::npos)
      count++;
  // Return the count.
  return count;
}
Exemple #4
0
bool bibleworks_is_running ()
// Returns whether BibleWorks runs.
// The reason this was introduced is so that older and future versions of BibleWorks are likely to be recognized.
{
  bool running = false;
  vector <ustring> processes = list_processes ();
  for (unsigned int i = 0; i < processes.size(); i++) {
    ustring process = lowerCase (processes[i]);
    size_t pos = process.find ("0.exe");
    if (pos != string::npos) {
      process.erase (0, pos - 6);
      pos = process.find ("bw");
      running = (pos != string::npos);
    }
  }
  return running;
}
int main (int argc, char **argv)
{
    /* this is the VM or file that we are looking at */
    if (argc != 2) {
        printf("Usage: %s <vmname>\n", argv[0]);
        return 1;
    }

#if ENABLE_SHM_SNAPSHOT == 1
    vmi_instance_t vmi;
    addr_t list_head = 0, current_list_entry = 0, next_list_entry = 0;
    addr_t current_process = 0;
    char *procname = NULL;
    vmi_pid_t pid = 0;
    unsigned long tasks_offset, pid_offset, name_offset;

    char *name = argv[1];

    /* initialize the libvmi library */
    if (vmi_init(&vmi, VMI_AUTO | VMI_INIT_COMPLETE, name) == VMI_FAILURE) {
        printf("Failed to init LibVMI library.\n");
        return 1;
    }

    /* init the offset values */
    if (VMI_OS_LINUX == vmi_get_ostype(vmi)) {
        tasks_offset = vmi_get_offset(vmi, "linux_tasks");
        name_offset = vmi_get_offset(vmi, "linux_name");
        pid_offset = vmi_get_offset(vmi, "linux_pid");

        /* NOTE: 
         *  name_offset is no longer hard-coded. Rather, it is now set 
         *  via libvmi.conf.
         */
    }
    else if (VMI_OS_WINDOWS == vmi_get_ostype(vmi)) {
        tasks_offset = vmi_get_offset(vmi, "win_tasks");
        if (0 == tasks_offset) {
            printf("Failed to find win_tasks\n");
            goto error_exit;
        }
        name_offset = vmi_get_offset(vmi, "win_pname");
        if (0 == name_offset) {
            printf("Failed to find win_pname\n");
            goto error_exit;
        }
        pid_offset = vmi_get_offset(vmi, "win_pid");
        if (0 == pid_offset) {
            printf("Failed to find win_pid\n");
            goto error_exit;
        }
    }

    /* create a shm-snapshot */
    if (vmi_shm_snapshot_create(vmi) != VMI_SUCCESS) {
        printf("Failed to shm-snapshot VM\n");
        goto error_exit;
    }

    /* demonstrate name and id accessors */
    list_processes(vmi, current_process, list_head, tasks_offset,
        current_list_entry, next_list_entry, pid_offset, pid,
        procname, name_offset);

    error_exit: if (procname)
        free(procname);

    /* destroy the shm-snapshot, and return live mode */
    vmi_shm_snapshot_destroy(vmi);

    /* cleanup any memory associated with the LibVMI instance */
    vmi_destroy(vmi);

    return 0;
#else
    printf("Error : this example should only run after ./configure --enable-shm-snapshot.\n");
    return 1; // error
#endif

}
Exemple #6
0
void NtProcessStartup( void )
{
	log_init();
	list_processes();
	log_fini();
}