Beispiel #1
0
static void
processes_kill(int sig)
{
    for (int i = 0; i < num_processes; i++) {
	bench_process_t *p = processes + i;
	if (process_running(p))
	    process_kill(p, sig);
    }
}
Beispiel #2
0
struct thread *syscall_exit(struct thread *image) {

	if (image->proc->pid == 1) {
		debug_panic("init died");
	}

	process_switch(process_get(1));
	process_kill(image->proc);

	return thread_switch(image, schedule_next());
}
void program_scheduler_shutdown(ProgramScheduler *program_scheduler) {
	if (program_scheduler->shutdown) {
		return;
	}

	program_scheduler->shutdown = true;

	program_scheduler_stop(program_scheduler, NULL);

	if (program_scheduler->last_spawned_process != NULL &&
	    process_is_alive(program_scheduler->last_spawned_process)) {
		process_kill(program_scheduler->last_spawned_process, PROCESS_SIGNAL_KILL);
	}
}
Beispiel #4
0
static void system_sysc_exit(PSW* m) {
    DEBUG_PRINTF(DEBUG_T_SYSC, "SYSCALL EXIT()\n");
    
    Process* process = process_current();
    
    if(process == NULL){
        DEBUG_PUTS(DEBUG_T_SYSTEM, "Pas de processus courant");
        return;
    }
    
    DEBUG_PRINTF(DEBUG_T_SYSTEM, "Suppr. proc %d\n", (int)process->number);
    
    process_kill(process);
    system_clock(m);
}
Beispiel #5
0
static int on_process(void* param, const char* name, pid_t pid)
{
	const char* p;
	const char* process = (const char*)param;

	p = path_basename(name);
#if defined(OS_WINDOWS)
	if(0 == stricmp(process, p))
#else
	if(0 == strcmp(process, p))
#endif
	{
		process_kill(pid);
	}
	return 0;
}
Beispiel #6
0
static gboolean
on_transport_control (CockpitTransport *transport,
                      const char *command,
                      const gchar *channel_id,
                      JsonObject *options,
                      GBytes *message,
                      gpointer user_data)
{
  CockpitRouter *self = user_data;

  if (g_str_equal (command, "init"))
    {
      process_init (self, transport, options);
      return TRUE;
    }

  if (!self->init_host)
    {
      g_warning ("caller did not send 'init' message first");
      cockpit_transport_close (transport, "protocol-error");
      return TRUE;
    }

  if (g_str_equal (command, "open"))
    {
      process_open (self, transport, channel_id, options, message);
      return TRUE;
    }
  else if (g_str_equal (command, "kill"))
    {
      process_kill (self, options);
      return TRUE;
    }
  else if (g_str_equal (command, "close"))
    {
      if (!channel_id)
        {
          g_warning ("Caller tried to close channel without an id");
          cockpit_transport_close (transport, "protocol-error");
        }
    }

  return FALSE;
}
Beispiel #7
0
void
alleyoop_kill (Alleyoop *grind)
{
	vg_tool_view_disconnect ((VgToolView *) grind->view);
	
	if (grind->gio) {
		g_io_channel_close (grind->gio);
		g_io_channel_unref (grind->gio);
		grind->watch_id = 0;
		grind->gio = NULL;
	}
	
	if (grind->pid != (pid_t) -1) {
		process_kill (grind->pid);
		grind->pid = (pid_t) -1;
	}
	
	gtk_widget_set_sensitive (grind->toolbar_run, TRUE);
	gtk_widget_set_sensitive (grind->toolbar_kill, FALSE);
}
Beispiel #8
0
struct thread *syscall_exit(struct thread *image) {
	struct thread *new_image;
	uint16_t pid;
	uint32_t parent;

	pid = image->proc->pid;

	if (pid == 1) {
		debug_panic("init died");
	}

	parent = image->proc->parent->pid;

	process_switch(process_get(1));

	new_image = thread_send(image, parent, PORT_CHILD, NULL);

	image->proc->status = image->eax;
	process_kill(image->proc);

	return new_image;
}
Beispiel #9
0
/*
 * Stop a particular process given its process struct.  This kills the
 * process, waits for it to exit if possible (giving it at most five seconds),
 * and then removes it from the global processes struct so that it isn't
 * stopped again during global shutdown.
 */
void
process_stop(struct process *process)
{
    int status;
    unsigned long pid = process->pid;

    /* Stop the process. */
    status = process_kill(process);

    /* Call diag to flush logs as well as provide exit status. */
    if (process->is_child)
        diag("stopped process %lu (exit status %d)", pid, status);
    else
        diag("stopped process %lu", pid);

    /* Remove the log and PID file. */
    diag_file_remove(process->logfile);
    unlink(process->pidfile);
    unlink(process->logfile);

    /* Free resources. */
    process_free(process);
}
int main(int argc, char *argv[]) {

	SRunner *sr;
	int_t failed = 0;
	time_t prog_start, test_start, test_end;

	if (process_kill(PLACER("magmad", 18), SIGTERM, 10) < 0) {
		log_unit("Another instance of the Magma Daemon is already running and refuses to die.");
		exit(EXIT_FAILURE);
	}

	// Setup
	prog_start = time(NULL);

	// Updates the location of the config file if it was specified on the command line.
	check_args_parse(argc, argv);

	if (do_virus_check && !virus_check_data_path) {
		virus_check_data_path = ns_dupe(VIRUS_CHECK_DATA_PATH);
	}

	if (do_tank_check && !tank_check_data_path) {
		tank_check_data_path = ns_dupe(TANK_CHECK_DATA_PATH);
	}

	if (do_dspam_check && !dspam_check_data_path) {
		dspam_check_data_path = ns_dupe(DSPAM_CHECK_DATA_PATH);
	}

	/*if (do_virus_check) printf("doing virus check: [%s]\n", !virus_check_data_path ? "NONE" : virus_check_data_path); else printf ("skipping virus check\n");
	if (do_tank_check) printf("doing tank check: [%s]\n", !tank_check_data_path ? "NONE" : tank_check_data_path); else printf ("skipping tank check\n");
	if (do_dspam_check) printf("doing dspam check: [%s]\n", !dspam_check_data_path ? "NONE" : dspam_check_data_path); else printf ("skipping dspam check\n");
	printf("config file: [%s]\n", magma.config.file);
	exit(EXIT_SUCCESS);*/

	if (!process_start()) {
		log_unit("Initialization error. Exiting.\n");
		status_set(-1);
		process_stop();
		exit(EXIT_FAILURE);
	}

	// Only during development...
	cache_flush();

	// Unit Test Config
	sr = srunner_create(suite_check_magma());

	// Add the suites.
	srunner_add_suite(sr, suite_check_core());
	srunner_add_suite(sr, suite_check_provide());
	srunner_add_suite(sr, suite_check_network());
	srunner_add_suite(sr, suite_check_objects());
	srunner_add_suite(sr, suite_check_users());

	// If were being run under Valgrind, we need to disable forking and increase the default timeout.
	// Under Valgrind, forked checks appear to improperly timeout.
	if (RUNNING_ON_VALGRIND == 0 && (failed = running_on_debugger()) == 0) {
		log_unit("Not being traced or profiled...\n");
		srunner_set_fork_status (sr, CK_FORK);
		case_timeout = RUN_TEST_CASE_TIMEOUT;
	}
	else {
		// Trace detection attempted was thwarted.
		if (failed == -1)	log_unit("Trace detection was thwarted.\n");
		else log_unit("Tracing or debugging is active...\n");
		srunner_set_fork_status (sr, CK_NOFORK);
		case_timeout = PROFILE_TEST_CASE_TIMEOUT;
	}

	// Execute
	log_unit("--------------------------------------------------------------------------\n");

	test_start = time(NULL);
	srunner_run_all(sr, CK_SILENT);
	test_end = time(NULL);

	// Output timing.
	log_unit("--------------------------------------------------------------------------\n");
	log_unit("%-63.63s %9lus\n", "TEST DURATION:", test_end - test_start);
	log_unit("%-63.63s %9lus\n", "TOTAL DURATION:", test_end - prog_start);

	// Summary
	log_unit("--------------------------------------------------------------------------\n");
	failed = srunner_ntests_failed(sr);
	srunner_print(sr, CK_NORMAL);

	// The Check Output Ending
	log_unit("--------------------------------------------------------------------------\n");

	// Cleanup and free the resources allocated by the check code.
	status_set(-1);
	srunner_free(sr);

	ns_cleanup(virus_check_data_path);
	ns_cleanup(tank_check_data_path);
	ns_cleanup(dspam_check_data_path);

	// Cleanup and free the resources allocated by the magma code.
	process_stop();
	system_init_umask();

	exit((failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
}
static void
dispatch_inbound_command (CockpitWebService *self,
                          CockpitSocket *socket,
                          GBytes *payload)
{
  const gchar *problem = "protocol-error";
  const gchar *command;
  const gchar *channel;
  JsonObject *options = NULL;
  gboolean valid = FALSE;

  valid = cockpit_transport_parse_command (payload, &command, &channel, &options);
  if (!valid)
    goto out;

  if (g_strcmp0 (command, "init") == 0)
    {
      problem = process_socket_init (self, socket, options);
      valid = (problem == NULL);
      goto out;
    }

  if (!socket->init_received)
    {
      g_message ("web socket did not send 'init' message first");
      valid = FALSE;
      goto out;
    }

  valid = TRUE;

  if (g_strcmp0 (command, "open") == 0)
    {
      valid = process_and_relay_open (self, socket, channel, options);
    }
  else if (g_strcmp0 (command, "authorize") == 0)
    {
      valid = process_socket_authorize (self, socket, channel, options, payload);
    }
  else if (g_strcmp0 (command, "logout") == 0)
    {
      valid = process_logout (self, options);
      if (valid)
        {
          /* logout is broadcast to everyone */
          if (!self->sent_done)
            cockpit_transport_send (self->transport, NULL, payload);
        }
    }
  else if (g_strcmp0 (command, "close") == 0)
    {
      if (channel == NULL)
        {
          g_warning ("got close command without a channel");
          valid = FALSE;
        }
      else
        {
          valid = process_and_relay_close (self, socket, channel, payload);
        }
    }
  else if (g_strcmp0 (command, "kill") == 0)
    {
      valid = process_kill (self, socket, options, payload);
    }
  else if (!channel && g_strcmp0 (command, "ping") == 0)
    {
      valid = process_ping (self, socket, options);
    }
  else if (channel)
    {
      /* Relay anything with a channel by default */
      if (!self->sent_done)
        cockpit_transport_send (self->transport, NULL, payload);
    }

out:
  if (!valid)
    inbound_protocol_error (self, socket->connection, problem);
  if (options)
    json_object_unref (options);
}
Beispiel #12
0
int process_exit(int exitcode)
{
	return process_kill(process_current[smp_cpu_id()]->pid);
}
Beispiel #13
0
		void Process::kill() {
			process_kill(this->obj);
		}