fdtrack: add wrappers for pipe, pipe2.
Bug: https://issuetracker.google.com/154450436
Test: bionic-unit-tests
Change-Id: I66826f312a65ab9f1bd8193bf684e330baa952dc
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index ab309e6..cf7d58b 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -126,7 +126,7 @@
int __fcntl:fcntl(int, int, void*) lp64
int flock(int, int) all
int __fchmod:fchmod(int, mode_t) all
-int pipe2(int*, int) all
+int __pipe2:pipe2(int*, int) all
int __dup:dup(int) all
int __dup3:dup3(int, int, int) all
int fsync(int) all
diff --git a/libc/bionic/pipe.cpp b/libc/bionic/pipe.cpp
index a81afe8..f197656 100644
--- a/libc/bionic/pipe.cpp
+++ b/libc/bionic/pipe.cpp
@@ -28,6 +28,24 @@
#include <unistd.h>
+#include "private/bionic_fdtrack.h"
+
+extern "C" int __pipe2(int pipefd[2], int flags);
+
int pipe(int pipefd[2]) {
- return pipe2(pipefd, 0);
+ int rc = __pipe2(pipefd, 0);
+ if (rc == 0) {
+ FDTRACK_CREATE(pipefd[0]);
+ FDTRACK_CREATE(pipefd[1]);
+ }
+ return rc;
+}
+
+int pipe2(int pipefd[2], int flags) {
+ int rc = __pipe2(pipefd, flags);
+ if (rc == 0) {
+ FDTRACK_CREATE(pipefd[0]);
+ FDTRACK_CREATE(pipefd[1]);
+ }
+ return rc;
}