Mon 14 Oct 23:09:15 CEST 2024

This commit is contained in:
sbosse 2024-10-14 23:09:54 +02:00
parent 33e37fb872
commit 88243e9dec

27
user/test/pipetest.c Normal file
View File

@ -0,0 +1,27 @@
#include "library/syscalls.h"
#include "library/user-io.h"
#include "library/string.h"
int main(int argc, char *argv[])
{
printf("%d: Running pipe test!\n", syscall_process_self());
int w = syscall_open_pipe();
syscall_object_set_blocking(w, 0);
int x = syscall_process_fork();
if(x) {
printf("%d: Writing...\n", syscall_process_self());
syscall_object_dup(w, KNO_STDOUT);
printf("Testing!\n");
syscall_process_sleep(1000);
} else {
printf("%d: Reading...\n", syscall_process_self());
int r;
char buf[10];
while(!(r = syscall_object_read(w, buf, 10))) {
syscall_process_yield();
}
printf("%d: I read %d chars from my brother\n", syscall_process_self(), r);
printf("%d: They are (%s)\n", syscall_process_self(), buf);
}
return 0;
}