From 42a909bbc8ede5c27e3d40606a98ab1251511dfc Mon Sep 17 00:00:00 2001 From: Halton Huo Date: Tue, 3 Nov 2009 11:42:07 +0800 Subject: Identify major device number for vt rather than hard code as 15. Fixes bug http://defect.opensolaris.org/bz/show_bug.cgi?id=12322 This is solaris only bug, won't affect other platform. --- src/ck-sysdeps-solaris.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ck-sysdeps-solaris.c b/src/ck-sysdeps-solaris.c index 607a3ae..335ab8b 100644 --- a/src/ck-sysdeps-solaris.c +++ b/src/ck-sysdeps-solaris.c @@ -124,6 +124,26 @@ ck_process_stat_get_tty (CkProcessStat *stat) return g_strdup (stat->tty_text); } +#define VT0_FILE "/dev/vt/0" +static int +get_system_vt_major () +{ + static ret = -1; + struct stat st; + int res; + + if (ret >= 0) + return ret; + + res = stat (VT0_FILE, &st); + + if (res == 0) { + ret = major (st.st_rdev); + } + + return ret; +} + /* return 1 if it works, or 0 for failure */ static gboolean stat2proc (pid_t pid, @@ -177,7 +197,7 @@ stat2proc (pid_t pid, snprintf (P->tty_text, sizeof P->tty_text, "%3d,%-3d", tty_maj, tty_min); - if (tty_maj == 15) { + if (tty_maj == get_system_vt_major ()) { snprintf (P->tty_text, sizeof P->tty_text, "/dev/vt/%u", tty_min); } if (P->tty == NO_TTY_VALUE) { -- cgit v1.2.3