<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85289>85289</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[libc] implement pipe2
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
libc
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
michaelrj-google
</td>
</tr>
</table>
<pre>
The pipe2 is defined on linux here: https://man7.org/linux/man-pages/man2/pipe.2.html
This is a simple syscall wrapper, so implementation should be straightforward.
### Build System
In [entrypoints.txt](https://github.com/llvm/llvm-project/blob/main/libc/config/linux/x86_64/entrypoints.txt)
- [ ] Add the new function to the list of entrypoints for unistd.h (you need to do this before it will build)
In [unistd/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libc/src/unistd/CMakeLists.txt)
- [ ] Add new entrypoint objects to the list
- [ ] Also add it to the list for unistd/linux/CMakeLists.txt
In [linux.td](https://github.com/llvm/llvm-project/blob/main/libc/spec/linux.td)
- [ ] Add the functions to the list of functions for unistd.h (this can be confusing, ask for help if you're stuck).
### Code
Create `unistd/pipe2.h`
- [ ] look at [dup.h](https://github.com/llvm/llvm-project/blob/main/libc/src/unistd/dup.h) for an example of how this should be laid out (copying the whole file and modifying it is fine).
Create `unistd/linux/pipe2.cpp`
- [ ] Again, look at look at [linux/dup.cpp](https://github.com/llvm/llvm-project/blob/main/libc/src/unistd/linux/dup.cpp) for an example.
### Testing
Create `test/src/unistd/pipe2_test.cpp`
- [ ] This needs to test the function succeeding and failing
- [ ] This is only testing the code you wrote, so don't worry too much about testing parts of the interface that the kernel handles.
Add your tests to [test/src/unistd/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/main/libc/test/src/unistd/CMakeLists.txt)
- [ ] Hopefully self-explanatory
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0ls9v6zYMx_8a5ULUcJQ4sQ85tCmCDdhO6_1BtmhL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