aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorMarek Polacek <mmpolacek@gmail.com>2010-10-28 21:34:56 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-28 21:34:56 +0200
commit7b18107384d950358e146d42bf02b391fab5ffd6 (patch)
tree9994e2bcaa038c3128ed8b3bca99486e22f660fb /miscutils
parent02788ac7e2a44eee889aa1005e89076f928e964a (diff)
downloadbusybox-7b18107384d950358e146d42bf02b391fab5ffd6.tar.gz
*: use _exit() in sighandlers; showkey: do not use exit-thru-sighandler
While at it, make ESC sequences more readable; and removed check for isatty(stdin) in reset. Code shrink: text data bss dec hex filename 884771 936 17216 902923 dc70b busybox_old 884723 936 17216 902875 dc6db busybox_unstripped Signed-off-by: Marek Polacek <mmpolacek@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/conspy.c13
-rw-r--r--miscutils/less.c14
-rw-r--r--miscutils/watchdog.c2
3 files changed, 17 insertions, 12 deletions
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 01928b35f..040fa86f3 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -43,6 +43,9 @@
#include "libbb.h"
#include <sys/kd.h>
+
+#define ESC "\033"
+
struct screen_info {
unsigned char lines, cols, cursor_x, cursor_y;
};
@@ -70,7 +73,7 @@ struct globals {
unsigned col;
unsigned line;
smallint curoff; // unknown:0 cursor on:-1 cursor off:1
- char attrbuf[sizeof("\033[0;1;5;30;40m")];
+ char attrbuf[sizeof(ESC"[0;1;5;30;40m")];
// remote console
struct screen_info remote;
// saved local tty terminfo
@@ -101,7 +104,7 @@ enum {
static void clrscr(void)
{
// Home, clear till end of screen
- fputs("\033[1;1H" "\033[J", stdout);
+ fputs(ESC"[1;1H" ESC"[J", stdout);
G.col = G.line = 0;
}
@@ -109,7 +112,7 @@ static void set_cursor(int state)
{
if (G.curoff != state) {
G.curoff = state;
- fputs("\033[?25", stdout);
+ fputs(ESC"[?25", stdout);
bb_putchar("h?l"[1 + state]);
}
}
@@ -119,7 +122,7 @@ static void gotoxy(int col, int line)
if (G.col != col || G.line != line) {
G.col = col;
G.line = line;
- printf("\033[%u;%uH", line + 1, col + 1);
+ printf(ESC"[%u;%uH", line + 1, col + 1);
}
}
@@ -132,7 +135,7 @@ static void cleanup(int code)
}
// Reset attributes
if (!BW)
- fputs("\033[0m", stdout);
+ fputs(ESC"[0m", stdout);
bb_putchar('\n');
if (code > 1)
kill_myself_with_sig(code);
diff --git a/miscutils/less.c b/miscutils/less.c
index 500059d2a..9e12c11a7 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -28,13 +28,15 @@
#include "xregex.h"
#endif
+
+#define ESC "\033"
/* The escape codes for highlighted and normal text */
-#define HIGHLIGHT "\033[7m"
-#define NORMAL "\033[0m"
+#define HIGHLIGHT ESC"[7m"
+#define NORMAL ESC"[0m"
/* The escape code to home and clear to the end of screen */
-#define CLEAR "\033[H\033[J"
+#define CLEAR ESC"[H\033[J"
/* The escape code to clear to the end of line */
-#define CLEAR_2_EOL "\033[K"
+#define CLEAR_2_EOL ESC"[K"
enum {
/* Absolute max of lines eaten */
@@ -165,12 +167,12 @@ static void set_tty_cooked(void)
top-left corner of the console */
static void move_cursor(int line, int row)
{
- printf("\033[%u;%uH", line, row);
+ printf(ESC"[%u;%uH", line, row);
}
static void clear_line(void)
{
- printf("\033[%u;0H" CLEAR_2_EOL, max_displayed_line + 2);
+ printf(ESC"[%u;0H" CLEAR_2_EOL, max_displayed_line + 2);
}
static void print_hilite(const char *str)
diff --git a/miscutils/watchdog.c b/miscutils/watchdog.c
index 36902a214..630782660 100644
--- a/miscutils/watchdog.c
+++ b/miscutils/watchdog.c
@@ -24,7 +24,7 @@ static void watchdog_shutdown(int sig UNUSED_PARAM)
write(3, &V, 1); /* Magic, see watchdog-api.txt in kernel */
if (ENABLE_FEATURE_CLEAN_UP)
close(3);
- exit(EXIT_SUCCESS);
+ _exit(EXIT_SUCCESS);
}
int watchdog_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;