From dad8b261ac7898f4d8cf537ad288ad6a1a74d124 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 9 Jul 2022 15:24:58 +0200 Subject: syscalls/pipe: turn into a POSIX-style api with separate rw ends Without separate read/write ends you can't tell when there are no more writers left if you have multiple readers. Consider this piece of code: int fd = pipe(); fork(); // execution continues in 2 processes while (read(fd, &some_buf, sizeof somebuf) >= 0) { ... } Once both processes call `read()`, it's obvious that no writes are possible - all the processes that hold a reference to the pipe are currently stuck on a `read()` call, so the kernel could just make it return an error in both. But, what then? It's still possible to write to the pipe, and you can't know if the other process will do that. Thus, if you don't want to miss any output, you have to keep reading the pipe. Forever. Both processes end up stuck. Having separate read/write ends prevents that. --- tools/syscall_wrappers.awk | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/syscall_wrappers.awk') diff --git a/tools/syscall_wrappers.awk b/tools/syscall_wrappers.awk index 12cc233..4a295f2 100644 --- a/tools/syscall_wrappers.awk +++ b/tools/syscall_wrappers.awk @@ -19,6 +19,7 @@ BEGIN { sub(/ *$/, "", rets) params = substr($0, match($0, /\(.+\)/) + 1, RLENGTH - 2); + gsub(/\[[^\]]\]/, "", params); if (params == "void") params = "" split(params, p, /,/); -- cgit v1.2.3