Пример #1
0
static Lisp_Object
inotifyevent_to_event (Lisp_Object watch, struct inotify_event const *ev)
{
  Lisp_Object name;
  uint32_t mask;
  CONS_TO_INTEGER (Fnth (make_number (3), watch), uint32_t, mask);

  if (! (mask & ev->mask))
    return Qnil;

  if (ev->len > 0)
    {
      size_t const len = strlen (ev->name);
      name = make_unibyte_string (ev->name, min (len, ev->len));
      name = DECODE_FILE (name);
    }
  else
    name = XCAR (XCDR (watch));

  return list2 (list4 (Fcons (INTEGER_TO_CONS (ev->wd), XCAR (watch)),
                       mask_to_aspects (ev->mask),
                       name,
		       INTEGER_TO_CONS (ev->cookie)),
		Fnth (make_number (2), watch));
}
Пример #2
0
static Lisp_Object
call_process_kill (Lisp_Object fdpid)
{
  int fd;
  pid_t pid;
  CONS_TO_INTEGER (Fcar (fdpid), int, fd);
  CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);
  emacs_close (fd);
  EMACS_KILLPG (pid, SIGKILL);
  synch_process_alive = 0;
  return Qnil;
}
Пример #3
0
static Lisp_Object
call_process_cleanup (Lisp_Object arg)
{
  Lisp_Object fdpid = Fcdr (arg);
  int fd;
#if defined (MSDOS)
  Lisp_Object file;
#else
  pid_t pid;
#endif

  Fset_buffer (Fcar (arg));
  CONS_TO_INTEGER (Fcar (fdpid), int, fd);

#if defined (MSDOS)
  /* for MSDOS fdpid is really (fd . tempfile)  */
  file = Fcdr (fdpid);
  /* FD is -1 and FILE is "" when we didn't actually create a
     temporary file in call-process.  */
  if (fd >= 0)
    emacs_close (fd);
  if (!(strcmp (SDATA (file), NULL_DEVICE) == 0 || SREF (file, 0) == '\0'))
    unlink (SDATA (file));
#else /* not MSDOS */
  CONS_TO_INTEGER (Fcdr (fdpid), pid_t, pid);

  if (call_process_exited)
    {
      emacs_close (fd);
      return Qnil;
    }

  if (EMACS_KILLPG (pid, SIGINT) == 0)
    {
      ptrdiff_t count = SPECPDL_INDEX ();
      record_unwind_protect (call_process_kill, fdpid);
      message1 ("Waiting for process to die...(type C-g again to kill it instantly)");
      immediate_quit = 1;
      QUIT;
      wait_for_termination (pid);
      immediate_quit = 0;
      specpdl_ptr = specpdl + count; /* Discard the unwind protect.  */
      message1 ("Waiting for process to die...done");
    }
  synch_process_alive = 0;
  emacs_close (fd);
#endif /* not MSDOS */
  return Qnil;
}