コード例 #1
0
ファイル: duplicogram.c プロジェクト: rixed/junkie
static void cap_callback(struct proto_subscriber unused_ *s, struct proto_info const unused_ *last, size_t cap_len, uint8_t const unused_ *packet, struct timeval const unused_ *now)
{
    if (! display_help) try_display(now);

    mutex_lock(&dup_lock);
    init();
    nb_nodups ++;
    sz_nodups += cap_len;
    mutex_unlock(&dup_lock);
}
コード例 #2
0
ファイル: meta-xwayland.c プロジェクト: ueno/mutter
static char *
create_lock_file (int display, int *display_out)
{
  char *filename;
  int fd;

  char pid[11];
  int size;
  int number_of_tries = 0;

  while (!try_display (display, &filename, &fd))
    {
      display++;
      number_of_tries++;

      /* If we can't get a display after 50 times, then something's wrong. Just
       * abort in this case. */
      if (number_of_tries >= 50)
        return NULL;
    }

  /* Subtle detail: we use the pid of the wayland compositor, not the xserver
   * in the lock file. */
  size = snprintf (pid, 11, "%10d\n", getpid ());
  if (size != 11 || write (fd, pid, 11) != 11)
    {
      unlink (filename);
      close (fd);
      g_warning ("failed to write pid to lock file %s", filename);
      g_free (filename);
      return NULL;
    }

  close (fd);

  *display_out = display;
  return filename;
}