diff --git a/src/libos/include/syscall.h b/src/libos/include/syscall.h
index a7cd296d..f4bc3f50 100644
--- a/src/libos/include/syscall.h
+++ b/src/libos/include/syscall.h
@@ -18,6 +18,7 @@ extern ssize_t occlum_readv(int fd, struct iovec* iov, int count);
extern ssize_t occlum_writev(int fd, const struct iovec* iov, int count);
extern off_t occlum_lseek(int fd, off_t offset, int whence);
extern int occlum_pipe(int fds[2]);
+extern int occlum_pipe2(int fds[2], int flags);
extern int occlum_spawn(int* child_pid, const char* path,
const char** argv,
diff --git a/src/libos/src/fs/file_table.rs b/src/libos/src/fs/file_table.rs
index b855390e..e1b22f02 100644
--- a/src/libos/src/fs/file_table.rs
+++ b/src/libos/src/fs/file_table.rs
@@ -4,71 +4,100 @@ use {std};
pub type FileDesc = u32;
-// Invariant 1: fd < max_fd, where fd is any fd in the table
-// Invariant 2: max_fd = table.size()
-// Invariant 3: num_fds <= table.size()
-#[derive(Clone, Debug, Default)]
+#[derive(Debug, Default)]
#[repr(C)]
pub struct FileTable {
- table: Vec