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[]) {
14
14
// We want the parent and child to each have their own file descriptor.
15
15
// So, we will create the file in the parent and then close it; then
16
16
// 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 );
18
18
if (fd < 0 )
19
19
exit (1 );
20
20
close (fd );
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
13
13
14
14
// We want the parent and child to share the file descriptor
15
15
// 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 );
17
17
if (fd < 0 )
18
18
exit (1 );
19
19
You can’t perform that action at this time.
0 commit comments