summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHalton Huo <halton.huo@sun.com>2009-11-03 11:42:07 +0800
committerHalton Huo <halton.huo@sun.com>2009-11-03 11:42:07 +0800
commit42a909bbc8ede5c27e3d40606a98ab1251511dfc (patch)
tree3d77f151cb04aa231288a61b485013f653f30751
parentb00450b3f9284d997e2e25fd470e7df7336f03ec (diff)
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.
-rw-r--r--src/ck-sysdeps-solaris.c22
1 files changed, 21 insertions, 1 deletions
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) {