From 6f8c220e0e43c7b456458ffc2e43cb9d4ba57a83 Mon Sep 17 00:00:00 2001 From: kevlo Date: Sat, 9 Jul 2011 07:43:56 +0000 Subject: - Add xdr_sizeof(3) to libc - Document xdr_sizeof(3); from NetBSD Discussed with: kib --- lib/libc/xdr/Makefile.inc | 4 +++- lib/libc/xdr/Symbol.map | 5 ++++- lib/libc/xdr/xdr.3 | 13 +++++++++++++ lib/libc/xdr/xdr_sizeof.c | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/xdr/Makefile.inc b/lib/libc/xdr/Makefile.inc index 2d360ac..d1bb208 100644 --- a/lib/libc/xdr/Makefile.inc +++ b/lib/libc/xdr/Makefile.inc @@ -3,7 +3,8 @@ .PATH: ${.CURDIR}/xdr ${.CURDIR}/. SRCS+= xdr.c xdr_array.c xdr_float.c xdr_mem.c \ - xdr_rec.c xdr_reference.c xdr_stdio.c + xdr_rec.c xdr_reference.c xdr_sizeof.c \ + xdr_stdio.c SYM_MAPS+= ${.CURDIR}/xdr/Symbol.map @@ -39,6 +40,7 @@ MLINKS+= rpc_xdr.3 xdr_accepted_reply.3 \ xdr.3 xdr_reference.3 \ xdr.3 xdr_setpos.3 \ xdr.3 xdr_short.3 \ + xdr.3 xdr_sizeof.3 \ xdr.3 xdrstdio_create.3 \ xdr.3 xdr_string.3 \ xdr.3 xdr_u_char.3 \ diff --git a/lib/libc/xdr/Symbol.map b/lib/libc/xdr/Symbol.map index 0739b7b..a8eb3a1 100644 --- a/lib/libc/xdr/Symbol.map +++ b/lib/libc/xdr/Symbol.map @@ -42,7 +42,6 @@ FBSD_1.0 { xdrrec_endofrecord; xdr_reference; xdr_pointer; - /* xdr_sizeof; */ /* Why is xdr_sizeof.c not included in Makefileinc? */ xdrstdio_create; }; @@ -51,3 +50,7 @@ FBSD_1.1 { xdr_uint32_t; xdr_uint64_t; }; + +FBSD_1.2 { + xdr_sizeof; +}; diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3 index 19c7e57..8998d06 100644 --- a/lib/libc/xdr/xdr.3 +++ b/lib/libc/xdr/xdr.3 @@ -31,6 +31,7 @@ .Nm xdr_reference , .Nm xdr_setpos , .Nm xdr_short , +.Nm xdr_sizeof, .Nm xdrstdio_create , .Nm xdr_string , .Nm xdr_u_char , @@ -561,6 +562,18 @@ A filter primitive that translates between C integers and their external representations. This routine returns one if it succeeds, zero otherwise. .Pp +.It Xo +.Ft unsigned long +.Xc +.It Xo +.Fn xdr_sizeof "xdrproc_t func" "void *data" +.Xc +.Pp +This routine returns the amount of memory required to encode +.Fa data +using filter +.Fa func . +.Pp .It Li "#ifdef _STDIO_H_" .It Li "/* XDR using stdio library */" .It Xo diff --git a/lib/libc/xdr/xdr_sizeof.c b/lib/libc/xdr/xdr_sizeof.c index 20f1c3a..f33c613 100644 --- a/lib/libc/xdr/xdr_sizeof.c +++ b/lib/libc/xdr/xdr_sizeof.c @@ -94,7 +94,7 @@ x_inline(xdrs, len) if (xdrs->x_op != XDR_ENCODE) { return (NULL); } - if (len < (u_int)xdrs->x_base) { + if (len < (u_int)(uintptr_t)xdrs->x_base) { /* x_private was already allocated */ xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); @@ -106,7 +106,7 @@ x_inline(xdrs, len) xdrs->x_base = 0; return (NULL); } - xdrs->x_base = (caddr_t) len; + xdrs->x_base = (caddr_t)(uintptr_t)len; xdrs->x_handy += len; return ((int32_t *) xdrs->x_private); } -- cgit v1.1 From cc28ca14955368eb370917a8e4df0bc005fb29b1 Mon Sep 17 00:00:00 2001 From: kevlo Date: Sun, 10 Jul 2011 06:57:00 +0000 Subject: Add a HISTORY section Requested by: arundel --- lib/libc/xdr/xdr.3 | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/libc') diff --git a/lib/libc/xdr/xdr.3 b/lib/libc/xdr/xdr.3 index 8998d06..69f2544 100644 --- a/lib/libc/xdr/xdr.3 +++ b/lib/libc/xdr/xdr.3 @@ -840,3 +840,8 @@ Returns one if it succeeds, zero otherwise. .%O RFC1014 .%Q "Sun Microsystems, Inc., USC\-ISI" .Re +.Sh HISTORY +The +.Nm xdr_sizeof +function first appeared in +.Fx 9.0 . -- cgit v1.1 From 3396d1eaffa995e1291d40431f4bbed3fc31df0d Mon Sep 17 00:00:00 2001 From: jilles Date: Sun, 10 Jul 2011 14:20:11 +0000 Subject: posix_spawn: If an error is detected in the child process, reap the zombie. Formerly, in this case an error was returned but the pid was also returned to the application, requiring the application to use unspecified behaviour (the returned pid in error situations) to avoid zombies. Now, reap the zombie and do not return the pid. MFC after: 2 weeks --- lib/libc/gen/posix_spawn.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/libc') diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index e4ceb20..e3124b2 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include "namespace.h" #include +#include #include #include @@ -216,7 +217,9 @@ do_posix_spawn(pid_t *pid, const char *path, error = errno; _exit(127); default: - if (pid != NULL) + if (error != 0) + _waitpid(p, NULL, WNOHANG); + else if (pid != NULL) *pid = p; return (error); } -- cgit v1.1 From 9ddcdc361153958f6fd170befab585e362283ac3 Mon Sep 17 00:00:00 2001 From: kib Date: Tue, 12 Jul 2011 20:38:42 +0000 Subject: Document RFTSIGZMB. Fix spelling of SIGCHLD. Note that signals are delivered, not returned. MFC after: 1 week --- lib/libc/sys/rfork.2 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lib/libc') diff --git a/lib/libc/sys/rfork.2 b/lib/libc/sys/rfork.2 index f1ae14b..222bac4 100644 --- a/lib/libc/sys/rfork.2 +++ b/lib/libc/sys/rfork.2 @@ -5,7 +5,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 15, 2011 +.Dd July 12, 2011 .Dt RFORK 2 .Os .Sh NAME @@ -84,8 +84,18 @@ Note that a lot of code will not run correctly in such an environment. .It Dv RFSIGSHARE If set, the kernel will force sharing the sigacts structure between the child and the parent. +.It Dv RFTSIGZMB +If set, the kernel will deliver a specified signal to the parent +upon the child exit, instead of default SIGCHLD. +The signal number +.Dv signum +is specified by oring the +.Dv RFTSIGFLAGS(signum) +expression into +.Fa flags . +Specifying signal number 0 disables signal delivery upon the child exit. .It Dv RFLINUXTHPN -If set, the kernel will return SIGUSR1 instead of SIGCHILD upon thread +If set, the kernel will deliver SIGUSR1 instead of SIGCHLD upon thread exit for the child. This is intended to mimic certain Linux clone behaviour. .El @@ -164,6 +174,8 @@ would be exceeded (see Both the RFFDG and the RFCFDG flags were specified. .It Bq Er EINVAL Any flags not listed above were specified. +.It Bq Er EINVAL +An invalid signal number was specified. .It Bq Er ENOMEM There is insufficient swap space for the new process. .El -- cgit v1.1