diff -d -urpN busybox.0/shell/ash.c busybox.1/shell/ash.c
--- busybox.0/shell/ash.c	2011-02-04 14:12:02.000000000 +0100
+++ busybox.1/shell/ash.c	2011-02-04 14:28:19.893877837 +0100
@@ -97,6 +97,14 @@
 //config:	help
 //config:	  Enable bash-compatible extensions.
 //config:
+//config:config ASH_IDLE_TIMEOUT
+//config:	bool "Idle timeout"
+//config:	default n
+//config:	depends on ASH
+//config:	help
+//config:	  Enables bash-like auto-logout after "$TMOUT" seconds of idle
+//config:	  time. The default value of "$TMOUT" is 300 seconds.
+//config:
 //config:config ASH_JOB_CONTROL
 //config:	bool "Job control"
 //config:	default y
@@ -12047,6 +12055,15 @@ evalcmd(int argc UNUSED_PARAM, char **ar
 	return exitstatus;
 }
 
+#if ENABLE_ASH_IDLE_TIMEOUT
+static smallint timed_out;
+
+static void alrm_catcher(int sig UNUSED_PARAM)
+{
+	timed_out = 1;
+}
+#endif
+
 /*
  * Read and execute commands.
  * "Top" is nonzero for the top level command loop;
@@ -12063,6 +12080,21 @@ cmdloop(int top)
 	TRACE(("cmdloop(%d) called\n", top));
 	for (;;) {
 		int skip;
+#if ENABLE_ASH_IDLE_TIMEOUT
+		int tmout_len = 0;
+
+		timed_out = 0;
+		if (iflag) {
+			const char *tmout_var = lookupvar("TMOUT");
+			if (tmout_var) {
+				tmout_len = atoi(tmout_var);
+				if (tmout_len > 0) {
+					signal(SIGALRM, alrm_catcher);
+					alarm(tmout_len);
+				}
+			}
+		}
+#endif
 
 		setstackmark(&smark);
 #if JOBS
@@ -12077,6 +12109,14 @@ cmdloop(int top)
 #endif
 		}
 		n = parsecmd(inter);
+#if ENABLE_ASH_IDLE_TIMEOUT
+		if (timed_out) {
+			printf("\007timed out waiting for input: auto-logout\n");
+			break;
+		}
+		if (tmout_len > 0)
+			alarm(0);
+#endif
 #if DEBUG
 		if (DEBUG > 2 && debug && (n != NODE_EOF))
 			showtree(n);
