Subject: NO_PID
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
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:

./sys/sys/proc.h:
#define	NO_PID		30001
./sys/kern/sys_pipe.c:
	pipe->pipe_pgid = NO_PID;
./sys/kern/sys_pipe.c:
	if (pid == NO_PID || pid == 0)
./sys/kern/tty.c:
	case TIOCGPGRP:                 /* get pgrp of tty */
		if (!isctty(p, tp))
			return (ENOTTY);
		*(int *)data = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
./sys/kern/kern_sysctl.c:
		ep->e_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
./sys/kern/kern_sysctl.c:
	ki->p_tpgid = NO_PID;	/* may be changed if controlling tty below */
./sys/kern/kern_sysctl.c:
		ki->p_tpgid = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
./lib/libkvm/kvm_proc.c:
			kp2p->p_tpgid = 30001 /* XXX NO_PID! */;
./sys/compat/linux/common/linux_file.c:
		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

-- 
David Laight: david@l8s.co.uk