diff options
Diffstat (limited to 'nullshell.c')
-rw-r--r-- | nullshell.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/nullshell.c b/nullshell.c index 9218c18..d053f8d 100644 --- a/nullshell.c +++ b/nullshell.c @@ -1,5 +1,5 @@ /* - * (C) 2013-2024 by Christian Hesse <mail@eworm.de> + * (C) 2013-2025 by Christian Hesse <mail@eworm.de> * * Based on ideas from Sleep Dummy Shell (SleepShell) * by Mario A. Valdez-Ramirez (http://www.mariovaldez.net/) @@ -40,22 +40,20 @@ void sig_callback(int signal) { int main(int argc, char **argv) { time_t now; - uint8_t start; + uint8_t lines = BANNERCONST; char *ssh_connection, *ssh_client, *ssh_tty; char * string = BANNER; - /* get the start time and calculate modulo */ - time(&now); - start = (now / 30) % 30; - /* read environment variables */ ssh_connection = getenv("SSH_CONNECTION"); ssh_client = getenv("SSH_CLIENT"); ssh_tty = getenv("SSH_TTY"); /* register signal callbacks */ - signal(SIGTERM, sig_callback); - signal(SIGINT, sig_callback); + struct sigaction act = { 0 }; + act.sa_handler = sig_callback; + sigaction(SIGINT, &act, NULL); + sigaction(SIGTERM, &act, NULL); /* clear the screen and set cursor to the top left * see 'man 4 console_codes' for details */ @@ -69,17 +67,19 @@ int main(int argc, char **argv) { printf("Terminal: %s\n", ssh_tty); } - /* print an character every SLEEPTIME seconds */ + /* print a character every SLEEPTIME milli-seconds */ while (1) { - sleep(SLEEPTIME); + usleep(SLEEPTIME * 1000); putchar(*string); fflush(NULL); if (*string == 0) { - time(&now); - if ((now / 30) % 30 != start) + if (lines-- > 0) { + time(&now); string = ctime(&now); - else + } else { string = BANNER; + lines = BANNERCONST; + } } else string++; } |