mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +00:00
Base: Update man2/pipe.md after 5d180d1f99
This commit is contained in:
parent
1803c5966d
commit
93f62384f5
1 changed files with 5 additions and 5 deletions
|
@ -36,10 +36,10 @@ int main()
|
|||
// Create the pipe.
|
||||
int pipefd[2];
|
||||
int rc = pipe(pipefd);
|
||||
ASSERT(rc == 0);
|
||||
VERIFY(rc == 0);
|
||||
|
||||
pid_t pid = fork();
|
||||
ASSERT(pid >= 0);
|
||||
VERIFY(pid >= 0);
|
||||
|
||||
if (pid == 0) {
|
||||
// Close the reading end of the pipe.
|
||||
|
@ -47,7 +47,7 @@ int main()
|
|||
// Write a message to the writing end of the pipe.
|
||||
static const char greeting[] = "Hello friends!";
|
||||
int nwritten = write(pipefd[1], greeting, sizeof(greeting));
|
||||
ASSERT(nwritten == sizeof(greeting));
|
||||
VERIFY(nwritten == sizeof(greeting));
|
||||
exit(0);
|
||||
} else {
|
||||
// Close the writing end of the pipe.
|
||||
|
@ -57,10 +57,10 @@ int main()
|
|||
// Read the message from the reading end of the pipe.
|
||||
char buffer[100];
|
||||
int nread = read(pipefd[0], buffer, sizeof(buffer));
|
||||
ASSERT(nread > 0);
|
||||
VERIFY(nread > 0);
|
||||
// Try to read again. We should get an EOF this time.
|
||||
nread = read(pipefd[0], buffer + nread, sizeof(buffer) - nread);
|
||||
ASSERT(nread == 0);
|
||||
VERIFY(nread == 0);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue