Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F111036466
D29880.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
593 B
Referenced Files
None
Subscribers
None
D29880.diff
View Options
Index: lib/libc/sys/fork.2
===================================================================
--- lib/libc/sys/fork.2
+++ lib/libc/sys/fork.2
@@ -118,13 +118,20 @@
case -1:
err(1, "Failed to fork");
case 0:
+ /*
+ * Using stdio safely around fork() requires at least flushing buffers
+ * and ensuring that opened FILEs are in some consistent state right
+ * at fork.
+ */
printf("Hello from child process!\en");
+ fflush(stdout);
exit(0);
default:
break;
}
printf("Hello from parent process (child's PID: %d)!\en", pid);
+ fflush(stdout);
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Feb 27, 12:58 PM (16 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16868928
Default Alt Text
D29880.diff (593 B)
Attached To
Mode
D29880: fork.2: Make the example more robust
Attached
Detach File
Event Timeline
Log In to Comment