Subject: NO_PID
To: None <>
From: David Laight <>
List: tech-kern
Date: 03/09/2003 22:11:31
Currently NO_PID is defined in sys/proc.h as 30001.
This is the only value that constrains PID_MAX to 30000.

Since this is only used to indicate the absence of a process group on a tty.
I suggest changing the name to NO_PGID, and the value to -1.
(PGIDs have to be +ve because they are passed as -ve PIDs in
some system calls).

The only uses of NO_PID or 30001 are:

#define	NO_PID		30001
	pipe->pipe_pgid = NO_PID;
	if (pid == NO_PID || pid == 0)
	case TIOCGPGRP:                 /* get pgrp of tty */
		if (!isctty(p, tp))
			return (ENOTTY);
		*(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
		ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
	ki->p_tpgid = NO_PID;	/* may be changed if controlling tty below */
		ki->p_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
			kp2p->p_tpgid = 30001 /* XXX NO_PID! */;
		if (cmd == LINUX_F_GETOWN) {
			retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
			return 0;

It isn't actually clear that 30001 is a 'good value' for the TIOCGPGRP
ioctl, nor the LINUX_F_GETOWN fcntl.
I don't know if isctty() can suceed when tp->t_pgrp is NULL.
Does anyone know offhand what linux itself returns?


David Laight: