COUNTORCAT(s, l, ps, n);
COUNTORCAT(s, l, ps, n); }
procfs_stat_gen(p, s, l)	struct proc *p;	char *s;	int l;{	struct session *sess;	struct tty *tp;	struct ucred *cr;	int pid, ppid, pgid, sid;	struct timeval ut, st;	char ps[256], *sep;	int i, n;	pid = p->p_pid;	ppid = p->p_pptr ? p->p_pptr->p_pid : 0;	pgid = p->p_pgrp->pg_id;	sess = p->p_pgrp->pg_session;	sid = sess->s_leader ? sess->s_leader->p_pid : 0;	n = 0;	if (s)		bzero(s, l);	bcopy(p->p_comm, ps, MAXCOMLEN-1);	ps[MAXCOMLEN] = '\0';	COUNTORCAT(s, l, ps, n);	(void) snprintf(ps, sizeof(ps), " %d %d %d %d ",	    pid, ppid, pgid, sid);	COUNTORCAT(s, l, ps, n);	if ((p->p_flag&P_CONTROLT) && (tp = sess->s_ttyp))		snprintf(ps, sizeof(ps), "%d,%d ",		    major(tp->t_dev), minor(tp->t_dev));	else		snprintf(ps, sizeof(ps), "%d,%d ",		    -1, -1);	COUNTORCAT(s, l, ps, n);	sep = "";	if (sess->s_ttyvp) {		snprintf(ps, sizeof(ps), "%sctty", sep);		sep = ",";	}	COUNTORCAT(s, l, ps, n);	if (SESS_LEADER(p)) {		snprintf(ps, sizeof(ps), "%ssldr", sep);		sep = ",";	}	COUNTORCAT(s, l, ps, n);	if (*sep != ',')		snprintf(ps, sizeof(ps), "noflags");	COUNTORCAT(s, l, ps, n);	if (p->p_flag & P_INMEM)		snprintf(ps, sizeof(ps), " %ld,%ld",		    p->p_stats->p_start.tv_sec, p->p_stats->p_start.tv_usec);	else		snprintf(ps, sizeof(ps), " -1,-1");	COUNTORCAT(s, l, ps, n);	calcru(p, &ut, &st, (void *) 0);	snprintf(ps, sizeof(ps), " %ld,%ld %ld,%ld",	    ut.tv_sec, ut.tv_usec, st.tv_sec, st.tv_usec);	COUNTORCAT(s, l, ps, n);	snprintf(ps, sizeof(ps), " %s",	    (p->p_wchan && p->p_wmesg) ? p->p_wmesg : "nochan");	COUNTORCAT(s, l, ps, n);	cr = p->p_ucred;	snprintf(ps, sizeof(ps), " %u, %u", cr->cr_uid, cr->cr_gid);	COUNTORCAT(s, l, ps, n);	for (i = 0; i < cr->cr_ngroups; i++) {		snprintf(ps, sizeof(ps), ",%u", cr->cr_groups[i]);		COUNTORCAT(s, l, ps, n);	}	snprintf(ps, sizeof(ps), "\n");	COUNTORCAT(s, l, ps, n);	return (s != NULL ? strlen(s) + 1 : n + 1);}