Page MenuHomeFreeBSD

D19058.id53528.diff
No OneTemporary

D19058.id53528.diff

Index: lib/libc/gen/posix_spawn.c
===================================================================
--- lib/libc/gen/posix_spawn.c
+++ lib/libc/gen/posix_spawn.c
@@ -203,7 +203,7 @@
pid_t p;
volatile int error = 0;
- p = vfork();
+ p = rfork(RFSPAWN);
switch (p) {
case -1:
return (errno);
Index: lib/libc/sys/rfork.2
===================================================================
--- lib/libc/sys/rfork.2
+++ lib/libc/sys/rfork.2
@@ -5,7 +5,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 12, 2011
+.Dd February 1, 2019
.Dt RFORK 2
.Os
.Sh NAME
@@ -34,7 +34,9 @@
The
.Fa flags
argument
-is the logical OR of some subset of:
+is either
+.Dv RFSPAWN
+or the logical OR of some subset of:
.Bl -tag -width ".Dv RFLINUXTHPN"
.It Dv RFPROC
If set a new process is created; otherwise changes affect the
@@ -105,6 +107,14 @@
or all processes sharing the table exit.
.Pp
If
+.Dv RFSPAWN
+is passed,
+.Nm
+will use
+.Xr vfork 2
+semantics but reset all signal actions in the child to default.
+.Pp
+If
.Dv RFPROC
is set, the
value returned in the parent process
Index: sys/kern/kern_fork.c
===================================================================
--- sys/kern/kern_fork.c
+++ sys/kern/kern_fork.c
@@ -175,7 +175,11 @@
AUDIT_ARG_FFLAGS(uap->flags);
bzero(&fr, sizeof(fr));
- fr.fr_flags = uap->flags;
+ if (uap->flags & RFSPAWN) {
+ fr.fr_flags = RFFDG | RFPROC | RFPPWAIT | RFMEM;
+ fr.fr_flags2 = FR2_SPAWN;
+ } else
+ fr.fr_flags = uap->flags;
fr.fr_pidp = &pid;
error = fork1(td, &fr);
if (error == 0) {
@@ -474,7 +478,8 @@
if (fr->fr_flags & RFSIGSHARE) {
p2->p_sigacts = sigacts_hold(p1->p_sigacts);
} else {
- sigacts_copy(newsigacts, p1->p_sigacts);
+ if (!(fr->fr_flags2 & FR2_SPAWN))
+ sigacts_copy(newsigacts, p1->p_sigacts);
p2->p_sigacts = newsigacts;
}
Index: sys/sys/proc.h
===================================================================
--- sys/sys/proc.h
+++ sys/sys/proc.h
@@ -997,6 +997,8 @@
int *fr_pd_fd;
int fr_pd_flags;
struct filecaps *fr_pd_fcaps;
+ int fr_flags2;
+#define FR2_SPAWN 0x00001
};
/*
Index: sys/sys/unistd.h
===================================================================
--- sys/sys/unistd.h
+++ sys/sys/unistd.h
@@ -189,10 +189,11 @@
#define RFTSIGFLAGS(signum) ((signum) << RFTSIGSHIFT)
#define RFPROCDESC (1<<28) /* return a process descriptor */
#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */
+#define RFSPAWN (1<<31) /* vfork(2) semantics, clear signals */
#define RFFLAGS (RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \
RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \
- RFPROCDESC | RFPPWAIT)
-#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT | RFPROCDESC)
+ RFPROCDESC | RFSPAWN | RFPPWAIT)
+#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPROCDESC)
#endif /* __BSD_VISIBLE */

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 21, 10:12 AM (1 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27111272
Default Alt Text
D19058.id53528.diff (2 KB)

Event Timeline