File tree 2 files changed +11
-6
lines changed 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 11
11
#include <fcntl.h>
12
12
#include <emscripten.h>
13
13
#include <assert.h>
14
+ #include <string.h>
14
15
15
16
16
17
int main () {
@@ -50,18 +51,20 @@ int main() {
50
51
printf ("\n" );
51
52
errno = 0 ;
52
53
53
-
54
54
printf ("DUP2 pipe\n" );
55
55
int p [2 ];
56
56
pipe (p );
57
57
int g = dup2 (p [0 ], 7 );
58
- write (p [1 ], "abc\n" , 3 );
59
- char buf [5 ];
60
- read (g , buf , 5 );
61
- // should print "buf: abc\n"
58
+ int rtn = write (p [1 ], "abc" , 3 );
59
+ assert (rtn == 3 );
60
+ char buf [5 ] = {0 };
61
+ rtn = read (g , buf , 5 );
62
+ assert (rtn == 3 );
62
63
printf ("buf: %s\n" , buf );
64
+ assert (strcmp (buf , "abc" ) == 0 );
65
+ printf ("\n" );
63
66
64
-
67
+ printf ( "DUP2 shared seek position\n" );
65
68
int fd1 = open ("./blah.txt" , O_RDWR | O_CREAT | O_EXCL , 0600 );
66
69
int fd2 = dup (fd1 );
67
70
int n = write (fd1 , "abcabc\n" , 7 );
Original file line number Diff line number Diff line change @@ -21,3 +21,5 @@ close(f): -1
21
21
22
22
DUP2 pipe
23
23
buf: abc
24
+
25
+ DUP2 shared seek position
You can’t perform that action at this time.
0 commit comments