File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -199,12 +199,18 @@ var SyscallsLibrary = {
199199 if (fdPtr == 0) {
200200 throw new FS.ErrnoError({{{ cDefs.EFAULT }}});
201201 }
202- if (flags && flags != {{{ cDefs.O_CLOEXEC }}}) {
202+ var validFlags = {{{ cDefs.O_CLOEXEC }}} | {{{ cDefs.O_NONBLOCK }}};
203+ if (flags & ~validFlags) {
203204 throw new FS.ErrnoError({{{ cDefs.ENOTSUP }}});
204205 }
205206
206207 var res = PIPEFS.createPipe();
207208
209+ if (flags & {{{ cDefs.O_NONBLOCK }}}) {
210+ FS.getStream(res.readable_fd).flags |= {{{ cDefs.O_NONBLOCK }}};
211+ FS.getStream(res.writable_fd).flags |= {{{ cDefs.O_NONBLOCK }}};
212+ }
213+
208214 {{{ makeSetValue('fdPtr', 0, 'res.readable_fd', 'i32') }}};
209215 {{{ makeSetValue('fdPtr', 4, 'res.writable_fd', 'i32') }}};
210216
Original file line number Diff line number Diff line change @@ -86,6 +86,14 @@ int main() {
8686 printf ("pipe2(bad): %d" , pipe2 (0 , 0 ));
8787 printf (", errno: %d\n" , errno );
8888 errno = 0 ;
89+ printf ("pipe2(O_NONBLOCK): %d" , pipe2 (pipe_arg , O_NONBLOCK ));
90+ printf (", errno: %d\n" , errno );
91+ printf ("pipe2(O_NONBLOCK) read flags: %d\n" , (fcntl (pipe_arg [0 ], F_GETFL ) & O_NONBLOCK ) != 0 );
92+ printf ("pipe2(O_NONBLOCK) write flags: %d\n" , (fcntl (pipe_arg [1 ], F_GETFL ) & O_NONBLOCK ) != 0 );
93+ errno = 0 ;
94+ printf ("pipe2(O_CLOEXEC|O_NONBLOCK): %d" , pipe2 (pipe_arg , O_CLOEXEC | O_NONBLOCK ));
95+ printf (", errno: %d\n" , errno );
96+ errno = 0 ;
8997
9098 char * exec_argv [] = {"arg" , 0 };
9199 char * exec_env [] = {"a=b" , 0 };
Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ pipe(good): 0, errno: 0
1515pipe(bad): -1, errno: 21
1616pipe2(good): 0, errno: 0
1717pipe2(bad): -1, errno: 21
18+ pipe2(O_NONBLOCK): 0, errno: 0
19+ pipe2(O_NONBLOCK) read flags: 1
20+ pipe2(O_NONBLOCK) write flags: 1
21+ pipe2(O_CLOEXEC|O_NONBLOCK): 0, errno: 0
1822execl: -1, errno: 45
1923execle: -1, errno: 45
2024execlp: -1, errno: 45
You can’t perform that action at this time.
0 commit comments