--- 2.6.18/drivers/char/n_tty.c +++ 2.6.18/drivers/char/n_tty.c @@ -48,6 +48,7 @@ #include #include +#include /* number of characters left in xmit buffer before select has we have room */ #define WAKEUP_CHARS 256 @@ -667,6 +668,37 @@ static inline void n_tty_receive_parity_ wake_up_interruptible(&tty->read_wait); } +#define LOAD_INT(x) ((x) >> FSHIFT) +#define LOAD_FRAC(x) LOAD_INT(((x) & (FIXED_1-1)) * 100) +const char *get_task_state(struct task_struct *tsk); + +static void +show_info(struct tty_struct *tty) +{ + struct task_struct *task = current; + unsigned long wchan = ~0; + cputime_t utime, stime; + char state, tcomm[sizeof(task->comm)], buf[1024]; + int len, load; + + get_task_comm(tcomm, task); + state = *get_task_state(task); + wchan = get_wchan(task); + utime = task->utime; + stime = task->stime; + load = avenrun[0] + (FIXED_1/200); + + memset(buf, 0, 1024); + + len = snprintf(buf, 1024, + "load: %d.%02d cmd: %s %d %c [%lx] %d.%02du %d.%02ds", + LOAD_INT(load), LOAD_FRAC(load), tcomm, task->pid, state, wchan, + cputime_to_msecs(utime) / 100, cputime_to_msecs(utime) % 100, + cputime_to_msecs(stime) / 100, cputime_to_msecs(stime) % 100); + + tty->driver->write(tty, buf, len); +} + /** * n_tty_receive_char - perform processing * @tty: terminal device @@ -764,6 +796,10 @@ send_signal: return; } } + if (c == 024) { + show_info(tty); + return; + } if (tty->icanon) { if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { @@ -1017,6 +1053,8 @@ static void n_tty_set_termios(struct tty if (I_INLCR(tty)) set_bit('\n', tty->process_char_map); + set_bit(024, tty->process_char_map); + if (L_ICANON(tty)) { set_bit(ERASE_CHAR(tty), tty->process_char_map); set_bit(KILL_CHAR(tty), tty->process_char_map); --- 2.6.18/fs/proc/array.c +++ 2.6.18/fs/proc/array.c @@ -138,7 +138,7 @@ static const char *task_state_array[] = "X (dead)" /* 32 */ }; -static inline const char * get_task_state(struct task_struct *tsk) +const char * get_task_state(struct task_struct *tsk) { unsigned int state = (tsk->state & (TASK_RUNNING | TASK_INTERRUPTIBLE |