diff options
author | toni <matzeton@googlemail.com> | 2017-01-13 14:02:38 +0100 |
---|---|---|
committer | toni <matzeton@googlemail.com> | 2017-01-13 14:02:38 +0100 |
commit | 701adbe9d743dbad0439cd2e7674311707766c77 (patch) | |
tree | 7890c2e3b6e6e7e95a2e9c1c90e8bb8f17a46ba6 | |
parent | 7a1cf85baa3396976615f721371a25aa7ea4c0cc (diff) |
updated tools..
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | dummyshell.c | 12 |
2 files changed, 12 insertions, 7 deletions
@@ -1,5 +1,5 @@ CC := gcc -CFLAGS := -O2 -g -Wall -ffunction-sections -fdata-sections -ffast-math -fomit-frame-pointer -fexpensive-optimizations +CFLAGS := -O2 -g -Wall -ffunction-sections -fdata-sections -ffast-math -fomit-frame-pointer -fexpensive-optimizations -Wl,--gc-sections LDFLAGS := RM := rm -rf LIBS := -lcurses @@ -48,6 +48,9 @@ xidle: xidle.o @echo 'Finished building target: $@' @echo ' ' +strip: + strip -s $(TARGETS) + clean: -$(RM) aes.o asciihexer.o dummyshell.o gol.o suidcmd.o xidle.o -$(RM) aes.d asciihexer.d dummyshell.d gol.d suidcmd.d xidle.d @@ -56,4 +59,4 @@ clean: rebuild: clean all -.PHONY: all clean +.PHONY: all clean strip diff --git a/dummyshell.c b/dummyshell.c index 28db234..c24f56b 100644 --- a/dummyshell.c +++ b/dummyshell.c @@ -219,7 +219,7 @@ static int init_msg(void) fprintf(stderr, "file (`%s`) mode should be 0664\n", MSGFILE); return -1; } - } else return -1; + } else if (errno != ENOENT) return -1; msgfd = open(MSGFILE, O_RDWR | O_CREAT | O_APPEND | O_DSYNC | O_RSYNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); if (msgfd < 0) { fprintf(stderr, "fopen(\"%s\") with write access: %s\n", MSGFILE, strerror(errno)); @@ -229,6 +229,7 @@ static int init_msg(void) return -2; } } + chmod(MSGFILE, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH); return 0; } @@ -528,12 +529,12 @@ int main(int argc, char** argv) fd_set fds; time_t start = time(NULL); time_t cur; - unsigned char mins = 0, hrs = 0; + unsigned char mins = 0, hrs = 0, doOnce = 1; while (doLoop > 0) { cur = time(NULL); double diff = difftime(cur, start); #if defined(_HAS_UTMP) || defined(_HAS_SYSINFO) - if ((unsigned int)diff % 60 == 0) { + if ((unsigned int)diff % 60 == 0 && doOnce) { if (diff != 0 && ++mins == 60) { mins = 0; hrs++; @@ -552,14 +553,15 @@ int main(int argc, char** argv) print_memusage(); print_cpuusage(); #endif - } + doOnce = 0; + } else doOnce = 1; #endif #ifdef _HAS_MSG while (print_msg() == 0) {} #endif switch (state) { case MS_DEFAULT: - printf("\r--- %02d:%02d:%02d ---%s", hrs, mins, ((unsigned int)diff % 60), keymsg); + printf("\33[2K\r--- %02d:%02d:%02d ---%s", hrs, mins, ((unsigned int)diff % 60), keymsg); break; case MS_MESSAGE: case MS_COMMAND: |