switch to type char - bsleep - Unnamed repository; edit this file 'description' to name the repository.
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 43c0e54a006befc029b8f050e71c5c1c90eb6903
DIR parent c712326312e6d2d51d99397d25ea9d1e137ff760
HTML Author: kroovy <me@kroovy.de>
Date: Tue, 25 Feb 2025 00:39:02 +0100
switch to type char
Diffstat:
M bsleep.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
DIR diff --git a/bsleep.c b/bsleep.c
@@ -9,19 +9,19 @@ int
main(void)
{
int i;
- int *shared_memory = mmap(NULL, sizeof(char), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+ char *shmem = mmap(NULL, sizeof(char), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0);
pid_t pid = fork();
if (pid == 0) {
/* CHILD */
for (i=1;;i++) {
- printf("\r[ press 'b' to interrupt: %ds ] [ '%c' was pressed ] ", i, *shared_memory); fflush(stdout);
+ printf("\r[ press 'b' to interrupt: %ds ] [ '%c' was pressed ] ", i, *shmem); fflush(stdout);
sleep(1);
}
} else {
/* PARENT */
system("/bin/stty raw -echo");
- while ((*shared_memory = getchar()) != 'b');
+ while ((*shmem = getchar()) != 'b');
kill(pid, SIGKILL);
system("/bin/stty cooked echo");
printf("\n");