Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142838531
D25588.id74175.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D25588.id74175.diff
View Options
Index: sys/compat/linprocfs/linprocfs.c
===================================================================
--- sys/compat/linprocfs/linprocfs.c
+++ sys/compat/linprocfs/linprocfs.c
@@ -767,6 +767,36 @@
return (0);
}
+static int
+linprocfs_get_tty_nr(struct proc *p)
+{
+ struct session *sp;
+ struct tty *tp;
+ const char *ttyname;
+ int error, major, minor, nr;
+
+ PROC_LOCK_ASSERT(p, MA_OWNED);
+
+ if ((p->p_flag & P_CONTROLT) == 0)
+ return (-1);
+
+ sp = p->p_pgrp->pg_session;
+ if (sp == NULL)
+ return (-1);
+
+ SESS_LOCK(sp);
+ tp = sp->s_ttyp;
+ SESS_UNLOCK(sp);
+
+ ttyname = devtoname(tp->t_dev);
+ error = linux_driver_get_major_minor(ttyname, &major, &minor);
+ if (error != 0)
+ return (-1);
+
+ nr = makedev(major, minor);
+ return (nr);
+}
+
/*
* Filler function for proc/pid/stat
*/
@@ -777,6 +807,7 @@
struct timeval boottime;
char state;
static int ratelimit = 0;
+ int tty_nr;
vm_offset_t startcode, startdata;
getboottime(&boottime);
@@ -808,11 +839,9 @@
PS_ADD("ppid", "%d", p->p_pptr ? p->p_pptr->p_pid : 0);
PS_ADD("pgrp", "%d", p->p_pgid);
PS_ADD("session", "%d", p->p_session->s_sid);
+ tty_nr = linprocfs_get_tty_nr(p);
PROC_UNLOCK(p);
- if (kp.ki_tdev == NODEV)
- PS_ADD("tty", "%s", "-1");
- else
- PS_ADD("tty", "%ju", (uintmax_t)kp.ki_tdev);
+ PS_ADD("tty", "%d", tty_nr);
PS_ADD("tpgid", "%d", kp.ki_tpgid);
PS_ADD("flags", "%u", 0); /* XXX */
PS_ADD("minflt", "%lu", kp.ki_rusage.ru_minflt);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 25, 1:40 AM (17 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27920207
Default Alt Text
D25588.id74175.diff (1 KB)
Attached To
Mode
D25588: Make linprocfs(5) report correct tty number in /proc/<PID>/stat
Attached
Detach File
Event Timeline
Log In to Comment