linprocfs: Make sure to report -1 as tty when we have no controlling tty.

When reporting a process' stats, we can't just provide the tty as an
unsigned long, as if we have no controlling tty, the tty would be NODEV, or
-1. Instaed, just special-case NODEV.

Submitted by:	Juraj Lutter <otis@sk.FreeBSD.org>
MFC after:	1 week
This commit is contained in:
Olivier Houchard 2019-11-11 00:21:05 +00:00
parent dc67cfef96
commit 2b2cde807c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=354602

View File

@ -809,7 +809,10 @@ linprocfs_doprocstat(PFS_FILL_ARGS)
PS_ADD("pgrp", "%d", p->p_pgid);
PS_ADD("session", "%d", p->p_session->s_sid);
PROC_UNLOCK(p);
PS_ADD("tty", "%ju", (uintmax_t)kp.ki_tdev);
if (kp.ki_tdev == NODEV)
PS_ADD("tty", "%s", "-1");
else
PS_ADD("tty", "%ju", (uintmax_t)kp.ki_tdev);
PS_ADD("tpgid", "%d", kp.ki_tpgid);
PS_ADD("flags", "%u", 0); /* XXX */
PS_ADD("minflt", "%lu", kp.ki_rusage.ru_minflt);