Пример #1
0
static void
stop_clicked_cb(GtkToolButton *button, gpointer user_data)
{
  // save zoom setting
  GcomprisProperties *properties = gc_prop_get();
  gc_prop_save(properties);

  gc_exit();
}
Пример #2
0
/*
 * Called once (from main) to clean up STM infrastructure.
 */
_CALLCONV void
stm_exit(void)
{
  PRINT_DEBUG("==> stm_exit()\n");

  if (!_tinystm.initialized)
    return;
  tls_exit();
  stm_quiesce_exit();

#ifdef EPOCH_GC
  gc_exit();
#endif /* EPOCH_GC */
  _tinystm.initialized = 0;
}
Пример #3
0
/*
 * Called once (from main) to clean up STM infrastructure.
 */
_CALLCONV void
stm_exit(void)
{
  PRINT_DEBUG("==> stm_exit()\n");

  if (!_tinystm.initialized)
    return;
  tls_exit();
  stm_quiesce_exit();


 #  ifdef STM_F2C2
  char filename[512];
  int cpu_id=0, fd;
  for (cpu_id=0; cpu_id<sysconf(_SC_NPROCESSORS_CONF); cpu_id++) {
	  sprintf(filename, "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_setspeed",cpu_id);
	  //printf("Filename: %s", filename);
	  fd=open(filename, O_WRONLY);
	  if(fd==-1){
		  printf("\nError opening file %s", filename);
		  exit(1);
	  }

	  char target_freq[]="800000";
	  write(fd, &target_freq, sizeof(target_freq));
	  close(fd);
  }

  if (semctl(semid, 0, IPC_RMID) < 0) {
          printf("\nCould not delete semaphore");
      }
#endif /* STM_F2C2 */

#ifdef EPOCH_GC
  gc_exit();
#endif /* EPOCH_GC */
  _tinystm.initialized = 0;
}
Пример #4
0
  static void
confirm_quit(gboolean answer)
{
  if (answer)
    gc_exit();
}
Пример #5
0
static int launch_child(struct handler *h) {
    // See if we already have a pid.
    if(h->deathcount >= 20) {
        printf("Handler %s marked as bad.\n", h->command);
        return 0;
    }
    if(h->pid != 0) {
        int status;

        // Check status of child process.
        int wait_result = waitpid(h->pid, &status, WNOHANG);
        if(!wait_result || !(WIFEXITED(status) || WIFSIGNALED(status))) {
            // If child has not exited, return immediately.
            // We don't want to start another.
            return 1;
        }
        else {
            fprintf(stderr, "Found dead handler: %s\n", h->command);
            h->deathcount++;
            close(h->fdin);
            close(h->fdout);
        }
        h->pid = 0;
        h->fdin = -1;
        h->fdout = -1;
    }

    int parent_in[2];
    int parent_out[2];

    pipe(parent_in);
    pipe(parent_out);

    pid_t pid = fork();
    if(pid == -1) {
        fprintf(stderr, "Failed to fork: %s\n", h->command);
        exit(1);
    }
    else if(pid) {
        //parent
        h->pid = pid;

        // Constant messages from transients are annoying.
        if(h->h_type == PERSISTENT) {
            fprintf(stderr, "Started child process: %d\n", pid);
        }

        close(parent_in[1]);
        close(parent_out[0]);
        h->fdin = parent_in[0];
        h->fdout = parent_out[1];

    }
    else {
        //child
        gc_exit();

        close(parent_in[0]);
        close(parent_out[1]);

        dup2(parent_in[1], STDOUT_FILENO);
        dup2(parent_out[0], STDIN_FILENO);
        char *env[1];
        env[0] = NULL;
        char *arg[1];
        arg[0] = NULL;
        execve(h->command, arg, environ);
        perror("Failed to launch handler");
        exit(1);
    }
    return 1;
}