1 commit 42a909bbc8ede5c27e3d40606a98ab1251511dfc 2 Author: Halton Huo <halton.huo (a] sun.com> 3 Date: Tue Nov 3 11:42:07 2009 +0800 4 5 Identify major device number for vt rather than hard code as 15. 6 Fixes bug http://defect.opensolaris.org/bz/show_bug.cgi?id=12322 7 This is solaris only bug, won't affect other platform. 8 9 diff --git a/src/ck-sysdeps-solaris.c b/src/ck-sysdeps-solaris.c 10 index 607a3ae..335ab8b 100644 11 --- a/src/ck-sysdeps-solaris.c 12 +++ b/src/ck-sysdeps-solaris.c 13 @@ -124,6 +124,26 @@ ck_process_stat_get_tty (CkProcessStat *stat) 14 return g_strdup (stat->tty_text); 15 } 16 17 +#define VT0_FILE "/dev/vt/0" 18 +static int 19 +get_system_vt_major () 20 +{ 21 + static ret = -1; 22 + struct stat st; 23 + int res; 24 + 25 + if (ret >= 0) 26 + return ret; 27 + 28 + res = stat (VT0_FILE, &st); 29 + 30 + if (res == 0) { 31 + ret = major (st.st_rdev); 32 + } 33 + 34 + return ret; 35 +} 36 + 37 /* return 1 if it works, or 0 for failure */ 38 static gboolean 39 stat2proc (pid_t pid, 40 @@ -177,7 +197,7 @@ stat2proc (pid_t pid, 41 42 snprintf (P->tty_text, sizeof P->tty_text, "%3d,%-3d", tty_maj, tty_min); 43 44 - if (tty_maj == 15) { 45 + if (tty_maj == get_system_vt_major ()) { 46 snprintf (P->tty_text, sizeof P->tty_text, "/dev/vt/%u", tty_min); 47 } 48 if (P->tty == NO_TTY_VALUE) { 49