Home
       disable echo for parent - bsleep - Unnamed repository; edit this file 'description' to name the repository.
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 790a606ba25554128182bb68647d0e27b14418cf
   DIR parent 2dfe127c86f38ac7366674bbb18443e608f213df
  HTML Author: kroovy <me@kroovy.de>
       Date:   Fri, 21 Feb 2025 11:34:14 +0100
       
       disable echo for parent
       
       Diffstat:
         M bsleep.c                            |      10 ++++------
       
       1 file changed, 4 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/bsleep.c b/bsleep.c
       @@ -25,18 +25,16 @@ main(void)
                case 0:
                        /* child */
                        for (i=1;;i++) {
       -                        printf("  press 'b' to interrupt: %ds    \r", i); fflush(stdout);
       +                        printf("  press 'b' to interrupt: %ds\r", i); fflush(stdout);
                                sleep(1);
                        }
                        exit(EXIT_SUCCESS);
                default:
                        /* parent */
       -                system("/bin/stty raw");
       -                while ((in = getchar()) != 'b') {
       -                        printf("%c ", in);
       -                }
       +                system("/bin/stty raw -echo");
       +                while ((in = getchar()) != 'b'); /* loop */
                        kill(pid, SIGKILL);
       -                system("/bin/stty cooked");
       +                system("/bin/stty cooked echo");
                        printf("\n");
                        exit(EXIT_SUCCESS);
                }