Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F166094732
D31425.id93279.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31425.id93279.diff
View Options
diff --git a/lib/libc/stdlib/exit.3 b/lib/libc/stdlib/exit.3
--- a/lib/libc/stdlib/exit.3
+++ b/lib/libc/stdlib/exit.3
@@ -32,7 +32,7 @@
.\" @(#)exit.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd March 22, 2020
+.Dd August 5, 2021
.Dt EXIT 3
.Os
.Sh NAME
@@ -76,6 +76,13 @@
function terminates without calling the functions registered with the
.Xr atexit 3
function, and may or may not perform the other actions listed.
+The
+.Fx
+implementation of the
+.Fn _Exit
+function does not flush buffers, does not close streams,
+and does not unlink temporal files.
+.Pp
Both functions make the low-order eight bits of the
.Fa status
argument available to a parent process which has called a
diff --git a/lib/libc/sys/fork.2 b/lib/libc/sys/fork.2
--- a/lib/libc/sys/fork.2
+++ b/lib/libc/sys/fork.2
@@ -28,7 +28,7 @@
.\" @(#)fork.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd August 2, 2021
+.Dd August 5, 2021
.Dt FORK 2
.Os
.Sh NAME
@@ -172,11 +172,27 @@
{
pid_t pid;
+ /*
+ * If child is expected to use stdio(3), state of
+ * the reused io streams must be synchronized between
+ * parent and child, to avoid double output at least.
+ */
+ fflush(stdout);
+
switch (pid = fork()) {
case -1:
err(1, "Failed to fork");
case 0:
printf("Hello from child process!\en");
+
+ /*
+ * Since we wrote into stdout, child needs to use
+ * exit(3) and not _exit(2). This causes handlers
+ * registered with atexit(3) to be called twice,
+ * once in parent, and once in the child. If such
+ * behavior is undesirable, consider
+ * terminating child with _exit(2) or _Exit(3).
+ */
exit(0);
default:
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 12, 4:38 PM (51 m, 45 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36568464
Default Alt Text
D31425.id93279.diff (1 KB)
Attached To
Mode
D31425: Some clarifications for fork(2) and _Exit(3) man pages
Attached
Detach File
Event Timeline
Log In to Comment