Am Dienstag 06 November 2007 schrieb walter harms:
> hi list,
> does the ash have an idle timeout ?
>
> (if not it would be a nice enhancement :)
Attached is a patch which adds this functionality to
ash (configurable via environment variable TMOUT).
Thomas
--- ash.c.orig 2007-12-14 09:18:05.000000000 +0100
+++ ash.c 2007-12-14 09:23:51.000000000 +0100
@@ -10856,6 +10856,17 @@
return exitstatus;
}
+#if ENABLE_ASH_IDLE_TIMEOUT
+static volatile int timed_out;
+
+static void alrm_catcher(int i)
+{
+ printf ("\007timed out waiting for input: auto-logout\n");
+ timed_out = 1;
+ return;
+}
+#endif
+
/*
* Read and execute commands. "Top" is nonzero for the top level command
* loop; it turns on prompting if the shell is interactive.
@@ -10867,11 +10878,30 @@
struct stackmark smark;
int inter;
int numeof = 0;
+#if ENABLE_ASH_IDLE_TIMEOUT
+ void *old_alrm;
+ int tmout_len;
+ char *tmout_var; /* timeout value for auto-logout */
+#endif
TRACE(("cmdloop(%d) called\n", top));
for (;;) {
int skip;
+#if ENABLE_ASH_IDLE_TIMEOUT
+ timed_out = 0;
+ tmout_var = NULL;
+ tmout_len = 0;
+ old_alrm = (void *)SIG_IGN;
+ if (iflag) {
+ if ((tmout_var = lookupvar("TMOUT")) != NULL
+ && (tmout_len = atoi(tmout_var)) > 0) {
+ signal(SIGALRM, alrm_catcher);
+ alarm(tmout_len);
+ }
+ }
+#endif
+
setstackmark(&smark);
#if JOBS
if (jobctl)
@@ -10885,6 +10915,15 @@
#endif
}
n = parsecmd(inter);
+#if ENABLE_ASH_IDLE_TIMEOUT
+ if (iflag && timed_out)
+ break;
+ if (iflag && tmout_var && (tmout_len > 0))
+ {
+ alarm(0);
+ signal(SIGALRM, old_alrm);
+ }
+#endif
/* showtree(n); DEBUG */
if (n == NEOF) {
if (!top || numeof >= 50)
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox