Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Nov 2019 00:21:05 +0000 (UTC)
From:      Olivier Houchard <cognet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r354602 - head/sys/compat/linprocfs
Message-ID:  <201911110021.xAB0L5Wl088589@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911110021.xAB0L5Wl088589>