summaryrefslogtreecommitdiff
path: root/usertests.c
blob: 62eefda30a6ffc38698157ed4a738654b80dc40f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// simple fork and pipe read/write

char buf[32];

void
pipe1()
{
  int fds[2], pid;

  pipe(fds);
  pid = pipe();
  if(pid == 0){
    write(fds[1], "xyz", 4);
  } else {
    read(fds[0], buf, sizeof(buf));
    if(buf[0] != 'x' || buf[1] != 'y'){
      puts("pipe1 oops\n");
      return;
    }
  }
  puts("pipe1 ok\n");
}

main()
{
  pipe1();

  while(1)
    ;
}