Function: process-running-child-p

process-running-child-p is a function defined in process.c.

Signature

(process-running-child-p &optional PROCESS)

Documentation

Return non-nil if PROCESS has given control of its terminal to a child.

If the operating system does not make it possible to find out, return t. If it's possible to find out, return the numeric ID of the foreground process group if PROCESS did give control of its terminal to a child process, and return nil if it didn't.

PROCESS must be a real subprocess, not a connection.

View in manual

Probably introduced at or before Emacs version 20.4.

Source Code

// Defined in /usr/src/emacs/src/process.c
{
  /* Initialize in case ioctl doesn't exist or gives an error,
     in a way that will cause returning t.  */
  Lisp_Object proc = get_process (process);
  struct Lisp_Process *p = XPROCESS (proc);

  if (!EQ (p->type, Qreal))
    error ("Process %s is not a subprocess",
	   SDATA (p->name));
  if (p->infd < 0)
    error ("Process %s is not active",
	   SDATA (p->name));

  pid_t gid = emacs_get_tty_pgrp (p);

  if (gid == p->pid)
    return Qnil;
  if (gid != -1)
    return make_fixnum (gid);
  return Qt;
}