File tree Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Expand file tree Collapse file tree 3 files changed +3
-3
lines changed Original file line number Diff line number Diff line change 1- PARENTPARENTchildPARENTchildPARENTchildPARENTchildPARENTchildPARENTPARENTPARENTPARENTchildchildchildchildchild
1+ childchildchildchildchildchildchildchildchildchildRENTPARENT
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
1414 // We want the parent and child to each have their own file descriptor.
1515 // So, we will create the file in the parent and then close it; then
1616 // we'll open it after the fork.
17- int fd = open ("data.out" , O_CREAT | O_WRONLY , 0644 );
17+ int fd = open ("data.out" , O_CREAT | O_WRONLY | O_TRUNC , 0644 );
1818 if (fd < 0 )
1919 exit (1 );
2020 close (fd );
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
1313
1414 // We want the parent and child to share the file descriptor
1515 // so we are going to open it BEFORE forking
16- int fd = open ("data.out" , O_CREAT | O_WRONLY , 0644 );
16+ int fd = open ("data.out" , O_CREAT | O_WRONLY | O_TRUNC , 0644 );
1717 if (fd < 0 )
1818 exit (1 );
1919
You can’t perform that action at this time.
0 commit comments