svn commit: r354602 - head/sys/compat/linprocfs

Olivier Houchard cognet at FreeBSD.org
Mon Nov 11 00:21:05 UTC 2019


Author: cognet
Date: Mon Nov 11 00:21:05 2019
New Revision: 354602
URL: https://svnweb.freebsd.org/changeset/base/354602

Log:
  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 at sk.FreeBSD.org>
  MFC after:	1 week

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- head/sys/compat/linprocfs/linprocfs.c	Sun Nov 10 22:08:07 2019	(r354601)
+++ head/sys/compat/linprocfs/linprocfs.c	Mon Nov 11 00:21:05 2019	(r354602)
@@ -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);


More information about the svn-src-all mailing list