From 12175ab5a406316bb00470acbcff3b589b1f343a Mon Sep 17 00:00:00 2001 From: glenda Date: Wed, 1 Apr 2026 18:29:42 +0000 Subject: [PATCH] whatever i was doing last time --- forking.c | 17 +++++++++++++++++ mkfile | 4 +++- qlock.c | 23 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 forking.c create mode 100644 qlock.c diff --git a/forking.c b/forking.c new file mode 100644 index 0000000000000000000000000000000000000000..4ba963c450abd67a94e10ff152102493b2a1d262 --- /dev/null +++ b/forking.c @@ -0,0 +1,17 @@ +#include +#include + +void +main(void) +{ + QLock lock; + + if(fork() == 0){ + qlock(&lock); + exits(nil); + }else{ + waitpid(); + qlock(&lock); + exits(nil); + } +} diff --git a/mkfile b/mkfile index 8be2705066ddbbd5730f70b2a68b1c24a0ea847d..5f77f9078f1f9494a60d049856eef4a1484b7cc2 100644 --- a/mkfile +++ b/mkfile @@ -6,7 +6,9 @@ bins=\ spiral\ queuesrv\ pres\ - ufx2font + ufx2font\ + forking\ + qlock all:VQ: `{echo $O.^$bins} diff --git a/qlock.c b/qlock.c new file mode 100644 index 0000000000000000000000000000000000000000..e415f7e05f58faae55d68ee08d16769b21951b5c --- /dev/null +++ b/qlock.c @@ -0,0 +1,23 @@ +#include +#include + +QLock l; + +int +on_note(void *, char *ty) +{ + fprint(2, "%d: note: %s\n", getpid(), ty); + return 0; +} + +void +main(int argc, char **argv) +{ + int pid; + + atnotify(on_note, 1); + + fork(); + + sleep(10000); +}