-/* $OpenBSD: tty.c,v 1.111 2014/07/12 18:43:32 tedu Exp $ */
+/* $OpenBSD: tty.c,v 1.112 2014/07/13 14:56:56 guenther Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
else if (tp->t_pgrp == NULL)
ttyprintf(tp, "no foreground process group\n");
else if ((pr = LIST_FIRST(&tp->t_pgrp->pg_members)) == NULL)
- ttyprintf(tp, "empty foreground process group\n");
+empty: ttyprintf(tp, "empty foreground process group\n");
else {
const char *state;
fixpt_t pctcpu, pctcpu2;
* Otherwise take the newest thread
*/
pick = p = TAILQ_FIRST(&pickpr->ps_threads);
+ if (p == NULL)
+ goto empty;
run = p->p_stat == SRUN || p->p_stat == SONPROC;
pctcpu = p->p_pctcpu;
while ((p = TAILQ_NEXT(p, p_thr_link)) != NULL) {