OpenWrt Forum Archive

Topic: busybox vi monopolizes cpu after logoff

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I often forget to close vi after editing some files, and logoff.
Since ash doesn't send $whatever signal to kill running processes when i log off, vi keeps running. The problem is that as soon as i have logged off, vi goes crazy and monopolizes all the cpu, which causes the router to crawl.
I suppose it isn't a problem if you logoff via the exit command since ash will refuse to do so if there are running processes, but i use putty so i regulary forget to kill those running jobs before logging off and my colo users yell at me because "i've messed something with the router again"  =/

So, is there an easy way to either :
- have ash send the appropriate signal ?
- do something about busybox vi so it doesn't behave like that ?
- find if some vi processes are running and nobody is logged in to kill them ?
I was about to write a little script to do that but noticed that "who" is not there... any idea on how to find if there are some users logged without it  ??

btw i have this vi behaviour on wrt54g v1.0 and 3.2 , with openwrt rc3 and rc4

samix wrote:

I often forget to close vi after editing some files, and logoff.

So, is there an easy way to either :

- do something about busybox vi so it doesn't behave like that ?


btw i have this vi behaviour on wrt54g v1.0 and 3.2 , with openwrt rc3 and rc4

Workarounds:
1) recompile busybox vi without signal handling :
menu config
  OpenWrt Package Selection ->  Busybox Configuration ->  Editors ->  Catch signals   
but you lose CTRL Z and window resize

or
2) patch busybox: in busybox/editors
--- vi.c.orig   2004-08-19 21:15:06.000000000 +0200
+++ vi.c        2006-01-01 14:16:21.000000000 +0100
@@ -2169,10 +2169,12 @@
//----- Come here when we get a signal ---------------------------
static void catch_sig(int sig)
{
+#if 0
        signal(SIGHUP, catch_sig);
        signal(SIGINT, catch_sig);
        signal(SIGTERM, catch_sig);
        signal(SIGALRM, catch_sig);
+#endif
        if(sig)
        longjmp(restart, sig);
}

Of course the right way would be to fix busybox.

The discussion might have continued from here.