aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/gen')
-rw-r--r--lib/libc/gen/Makefile.inc2
-rw-r--r--lib/libc/gen/Symbol.map5
-rw-r--r--lib/libc/gen/closedir.c11
-rw-r--r--lib/libc/gen/directory.315
-rw-r--r--lib/libc/gen/dl_iterate_phdr.32
-rw-r--r--lib/libc/gen/dup3.3116
-rw-r--r--lib/libc/gen/dup3.c59
-rw-r--r--lib/libc/gen/errlst.c8
-rw-r--r--lib/libc/gen/fnmatch.c2
-rw-r--r--lib/libc/gen/fts-compat.h6
-rw-r--r--lib/libc/gen/fts.34
-rw-r--r--lib/libc/gen/getlogin.c2
-rw-r--r--lib/libc/gen/popen.37
-rw-r--r--lib/libc/gen/popen.c30
-rw-r--r--lib/libc/gen/posix_spawn_file_actions_addopen.329
-rw-r--r--lib/libc/gen/pututxline.c12
-rw-r--r--lib/libc/gen/sem_wait.39
-rw-r--r--lib/libc/gen/siginterrupt.c2
-rw-r--r--lib/libc/gen/signal.31
-rw-r--r--lib/libc/gen/signal.c2
-rw-r--r--lib/libc/gen/stringlist.32
-rw-r--r--lib/libc/gen/stringlist.c14
-rw-r--r--lib/libc/gen/strtofflags.c20
-rw-r--r--lib/libc/gen/sysconf.34
-rw-r--r--lib/libc/gen/sysctl.322
-rw-r--r--lib/libc/gen/wordexp.c27
26 files changed, 330 insertions, 83 deletions
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index fac1e43f2fd0..a88150c2035c 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -31,6 +31,7 @@ SRCS+= __getosreldate.c \
disklabel.c \
dlfcn.c \
drand48.c \
+ dup3.c \
elf_utils.c \
erand48.c \
err.c \
@@ -184,6 +185,7 @@ MAN+= alarm.3 \
dlinfo.3 \
dllockinit.3 \
dlopen.3 \
+ dup3.3 \
err.3 \
exec.3 \
feature_present.3 \
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 243895137210..5885420bb24a 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -383,7 +383,9 @@ FBSD_1.2 {
FBSD_1.3 {
clock_getcpuclockid;
dirfd;
- fdlopen;
+ dup3;
+ fdclosedir;
+ fdlopen;
__FreeBSD_libc_enter_restricted_mode;
getcontextx;
gid_from_group;
@@ -529,5 +531,6 @@ FBSDprivate_1.0 {
__elf_aux_vector;
__pthread_map_stacks_exec;
__fillcontextx;
+ __fillcontextx2;
__getcontextx_size;
};
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 4b520cc458ae..88ded37be51f 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
* close a directory.
*/
int
-closedir(DIR *dirp)
+fdclosedir(DIR *dirp)
{
int fd;
@@ -65,5 +65,12 @@ closedir(DIR *dirp)
_pthread_mutex_destroy(&dirp->dd_lock);
}
free((void *)dirp);
- return(_close(fd));
+ return (fd);
+}
+
+int
+closedir(DIR *dirp)
+{
+
+ return (_close(fdclosedir(dirp)));
}
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 0fd5bba32b7a..4573d4513fe2 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -28,7 +28,7 @@
.\" @(#)directory.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd July 5, 2012
+.Dd August 18, 2013
.Dt DIRECTORY 3
.Os
.Sh NAME
@@ -40,6 +40,7 @@
.Nm seekdir ,
.Nm rewinddir ,
.Nm closedir ,
+.Nm fdclosedir ,
.Nm dirfd
.Nd directory operations
.Sh LIBRARY
@@ -64,6 +65,8 @@
.Ft int
.Fn closedir "DIR *dirp"
.Ft int
+.Fn fdclosedir "DIR *dirp"
+.Ft int
.Fn dirfd "DIR *dirp"
.Sh DESCRIPTION
The
@@ -208,6 +211,13 @@ On failure, \-1 is returned and the global variable
is set to indicate the error.
.Pp
The
+.Fn fdclosedir
+function is equivalent to the
+.Fn closedir
+function except that this function returns directory file descriptor instead of
+closing it.
+.Pp
+The
.Fn dirfd
function
returns the integer file descriptor associated with the named
@@ -252,6 +262,9 @@ The
.Fn fdopendir
function appeared in
.Fx 8.0 .
+.Fn fdclosedir
+function appeared in
+.Fx 10.0 .
.Sh BUGS
The invalidation of
.Fn telldir
diff --git a/lib/libc/gen/dl_iterate_phdr.3 b/lib/libc/gen/dl_iterate_phdr.3
index f148ab104c4e..5b8afc6a09f4 100644
--- a/lib/libc/gen/dl_iterate_phdr.3
+++ b/lib/libc/gen/dl_iterate_phdr.3
@@ -29,7 +29,7 @@ Statically linked programs use an implementation of
.Fn dl_iterate_phdr
from libc.
.Sh SYNOPSIS
-.Fd #include <link.h>
+.In link.h
.Ft int
.Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
.Sh DESCRIPTION
diff --git a/lib/libc/gen/dup3.3 b/lib/libc/gen/dup3.3
new file mode 100644
index 000000000000..d3bb116189b7
--- /dev/null
+++ b/lib/libc/gen/dup3.3
@@ -0,0 +1,116 @@
+.\" Copyright (c) 2013 Jilles Tjoelker
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd August 16, 2013
+.Dt DUP3 3
+.Os
+.Sh NAME
+.Nm dup3
+.Nd duplicate an existing file descriptor
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In fcntl.h
+.In unistd.h
+.Ft int
+.Fn dup3 "int oldd" "int newd" "int flags"
+.Sh DESCRIPTION
+The
+.Fn dup3
+function
+duplicates an existing object descriptor
+while allowing the value of the new descriptor to be specified.
+.Pp
+The close-on-exec flag on the new file descriptor is determined by the
+.Dv O_CLOEXEC
+bit in
+.Fa flags .
+.Pp
+If
+.Fa oldd
+\*(Ne
+.Fa newd
+and
+.Fa flags
+== 0,
+the behavior is identical to
+.Li dup2(oldd, newd) .
+.Pp
+If
+.Fa oldd
+==
+.Fa newd ,
+then
+.Fn dup3
+fails, unlike
+.Xr dup2 2 .
+.Sh RETURN VALUES
+The value -1 is returned if an error occurs.
+The external variable
+.Va errno
+indicates the cause of the error.
+.Sh ERRORS
+The
+.Fn dup3
+function fails if:
+.Bl -tag -width Er
+.It Bq Er EBADF
+The
+.Fa oldd
+argument is not a valid active descriptor or the
+.Fa newd
+argument is negative or exceeds the maximum allowable descriptor number
+.It Bq Er EINVAL
+The
+.Fa oldd
+argument is equal to the
+.Fa newd
+argument.
+.It Bq Er EINVAL
+The
+.Fa flags
+argument has bits set other than
+.Dv O_CLOEXEC .
+.El
+.Sh SEE ALSO
+.Xr accept 2 ,
+.Xr close 2 ,
+.Xr dup2 2 ,
+.Xr fcntl 2 ,
+.Xr getdtablesize 2 ,
+.Xr open 2 ,
+.Xr pipe 2 ,
+.Xr socket 2 ,
+.Xr socketpair 2
+.Sh STANDARDS
+The
+.Fn dup3
+function does not conform to any standard.
+.Sh HISTORY
+The
+.Fn dup3
+function appeared in
+.Fx 10.0 .
diff --git a/lib/libc/gen/dup3.c b/lib/libc/gen/dup3.c
new file mode 100644
index 000000000000..ac8877cdc8a6
--- /dev/null
+++ b/lib/libc/gen/dup3.c
@@ -0,0 +1,59 @@
+/*-
+ * Copyright (c) 2012 Jukka A. Ukkonen
+ * All rights reserved.
+ *
+ * This software was developed by Jukka Ukkonen for FreeBSD.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "namespace.h"
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "un-namespace.h"
+
+int
+__dup3(int oldfd, int newfd, int flags)
+{
+ int how;
+
+ if (oldfd == newfd) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ if (flags & ~O_CLOEXEC) {
+ errno = EINVAL;
+ return (-1);
+ }
+
+ how = (flags & O_CLOEXEC) ? F_DUP2FD_CLOEXEC : F_DUP2FD;
+
+ return (_fcntl(oldfd, how, newfd));
+}
+
+__weak_reference(__dup3, dup3);
+__weak_reference(__dup3, _dup3);
diff --git a/lib/libc/gen/errlst.c b/lib/libc/gen/errlst.c
index d8178236deed..f8fe9684a26a 100644
--- a/lib/libc/gen/errlst.c
+++ b/lib/libc/gen/errlst.c
@@ -34,6 +34,7 @@ static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93";
__FBSDID("$FreeBSD$");
#include <stdio.h>
+#include "errlst.h"
const char *const sys_errlist[] = {
"No error: 0", /* 0 - ENOERROR */
@@ -152,5 +153,12 @@ const char *const sys_errlist[] = {
"Protocol error", /* 92 - EPROTO */
"Capabilities insufficient", /* 93 - ENOTCAPABLE */
"Not permitted in capability mode", /* 94 - ECAPMODE */
+ "State not recoverable", /* 95 - ENOTRECOVERABLE */
+ "Previous owner died", /* 96 - EOWNERDEAD */
};
const int sys_nerr = sizeof(sys_errlist) / sizeof(sys_errlist[0]);
+
+#ifdef PIC
+__strong_reference(sys_errlist, __hidden_sys_errlist);
+__strong_reference(sys_nerr, __hidden_sys_nerr);
+#endif
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c
index c38aafc8b0b5..47d0a4131f5c 100644
--- a/lib/libc/gen/fnmatch.c
+++ b/lib/libc/gen/fnmatch.c
@@ -194,8 +194,6 @@ fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs)
&patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
- if (pclen == 0)
- pc = '\\';
pattern += pclen;
}
/* FALLTHROUGH */
diff --git a/lib/libc/gen/fts-compat.h b/lib/libc/gen/fts-compat.h
index dfdd53bfb65c..d8fe6895f11c 100644
--- a/lib/libc/gen/fts-compat.h
+++ b/lib/libc/gen/fts-compat.h
@@ -10,11 +10,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3
index 35e4d459238f..9133e378f66b 100644
--- a/lib/libc/gen/fts.3
+++ b/lib/libc/gen/fts.3
@@ -28,7 +28,7 @@
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
.\" $FreeBSD$
.\"
-.Dd March 18, 2012
+.Dd May 21, 2013
.Dt FTS 3
.Os
.Sh NAME
@@ -37,8 +37,6 @@
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
-.In sys/types.h
-.In sys/stat.h
.In fts.h
.Ft FTS *
.Fn fts_open "char * const *path_argv" "int options" "int (*compar)(const FTSENT * const *, const FTSENT * const *)"
diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c
index 569cf4276ad9..4dab3cb07f28 100644
--- a/lib/libc/gen/getlogin.c
+++ b/lib/libc/gen/getlogin.c
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
extern int _getlogin(char *, int);
-int _logname_valid; /* known to setlogin() */
+int _logname_valid __hidden; /* known to setlogin() */
static pthread_mutex_t logname_mutex = PTHREAD_MUTEX_INITIALIZER;
static char *
diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3
index 90297e46f728..386a0bdf9857 100644
--- a/lib/libc/gen/popen.3
+++ b/lib/libc/gen/popen.3
@@ -28,7 +28,7 @@
.\" @(#)popen.3 8.2 (Berkeley) 5/3/95
.\" $FreeBSD$
.\"
-.Dd May 3, 1995
+.Dd May 20, 2013
.Dt POPEN 3
.Os
.Sh NAME
@@ -79,6 +79,11 @@ for writing, or
.Ql r+
for reading and writing.
.Pp
+A letter
+.Ql e
+may be appended to that to request that the underlying file descriptor
+be set close-on-exec.
+.Pp
The
.Fa command
argument is a pointer to a null-terminated string
diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c
index b123234837ee..b0597c80783f 100644
--- a/lib/libc/gen/popen.c
+++ b/lib/libc/gen/popen.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
#include <errno.h>
+#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -71,10 +72,11 @@ popen(command, type)
{
struct pid *cur;
FILE *iop;
- int pdes[2], pid, twoway;
+ int pdes[2], pid, twoway, cloexec;
char *argv[4];
struct pid *p;
+ cloexec = strchr(type, 'e') != NULL;
/*
* Lite2 introduced two-way popen() pipes using _socketpair().
* FreeBSD's pipe() is bidirectional, so we use that.
@@ -84,10 +86,11 @@ popen(command, type)
type = "r+";
} else {
twoway = 0;
- if ((*type != 'r' && *type != 'w') || type[1])
+ if ((*type != 'r' && *type != 'w') ||
+ (type[1] && (type[1] != 'e' || type[2])))
return (NULL);
}
- if (pipe(pdes) < 0)
+ if ((cloexec ? pipe2(pdes, O_CLOEXEC) : pipe(pdes)) < 0)
return (NULL);
if ((cur = malloc(sizeof(struct pid))) == NULL) {
@@ -120,20 +123,29 @@ popen(command, type)
* the compiler is free to corrupt all the local
* variables.
*/
- (void)_close(pdes[0]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
if (pdes[1] != STDOUT_FILENO) {
(void)_dup2(pdes[1], STDOUT_FILENO);
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[1]);
if (twoway)
(void)_dup2(STDOUT_FILENO, STDIN_FILENO);
- } else if (twoway && (pdes[1] != STDIN_FILENO))
+ } else if (twoway && (pdes[1] != STDIN_FILENO)) {
(void)_dup2(pdes[1], STDIN_FILENO);
+ if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
+ } else if (cloexec)
+ (void)_fcntl(pdes[1], F_SETFD, 0);
} else {
if (pdes[0] != STDIN_FILENO) {
(void)_dup2(pdes[0], STDIN_FILENO);
- (void)_close(pdes[0]);
- }
- (void)_close(pdes[1]);
+ if (!cloexec)
+ (void)_close(pdes[0]);
+ } else if (cloexec)
+ (void)_fcntl(pdes[0], F_SETFD, 0);
+ if (!cloexec)
+ (void)_close(pdes[1]);
}
SLIST_FOREACH(p, &pidlist, next)
(void)_close(fileno(p->fp));
diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3
index c6fd017f22d1..9cd47efb02da 100644
--- a/lib/libc/gen/posix_spawn_file_actions_addopen.3
+++ b/lib/libc/gen/posix_spawn_file_actions_addopen.3
@@ -34,7 +34,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 24, 2008
+.Dd May 9, 2013
.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3
.Os
.Sh NAME
@@ -123,7 +123,19 @@ to be duplicated as
dup2(fildes, newfildes)
.Ed
.Pp
-had been called) when a new process is spawned using this file actions object.
+had been called) when a new process is spawned using this file actions object,
+except that the
+.Dv FD_CLOEXEC
+flag for
+.Fa newfildes
+is cleared even if
+.Fa fildes
+is equal to
+.Fa newfildes .
+The difference from
+.Fn dup2
+is useful for passing a particular file descriptor
+to a particular child process.
.Pp
The
.Fn posix_spawn_file_actions_addclose
@@ -145,7 +157,7 @@ otherwise, an error number is returned to indicate the error.
These
functions fail if:
.Bl -tag -width Er
-.It Bq Er EINVAL
+.It Bq Er EBADF
The value specified by
.Fa fildes
or
@@ -169,7 +181,16 @@ The
and
.Fn posix_spawn_file_actions_addclose
functions conform to
-.St -p1003.1-2001 .
+.St -p1003.1-2001 ,
+with the exception of the behavior of
+.Fn posix_spawn_file_actions_adddup2
+if
+.Fa fildes
+is equal to
+.Fa newfildes
+(clearing
+.Dv FD_CLOEXEC ) .
+A future update of the Standard is expected to require this behavior.
.Sh HISTORY
The
.Fn posix_spawn_file_actions_addopen ,
diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c
index 555386c549c0..4982c0276fbf 100644
--- a/lib/libc/gen/pututxline.c
+++ b/lib/libc/gen/pututxline.c
@@ -131,7 +131,8 @@ exact:
else
error = 0;
fclose(fp);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
@@ -169,7 +170,8 @@ utx_active_remove(struct futx *fu)
}
fclose(fp);
- errno = error;
+ if (ret != 0)
+ errno = error;
return (ret);
}
@@ -225,7 +227,8 @@ utx_lastlogin_add(const struct futx *fu)
ret = -1;
}
fclose(fp);
- errno = error;
+ if (ret == -1)
+ errno = error;
return (ret);
}
@@ -277,7 +280,8 @@ utx_log_add(const struct futx *fu)
else
error = 0;
_close(fd);
- errno = error;
+ if (error != 0)
+ errno = error;
return (error == 0 ? 0 : 1);
}
diff --git a/lib/libc/gen/sem_wait.3 b/lib/libc/gen/sem_wait.3
index 18e95868f202..993ac4a15a29 100644
--- a/lib/libc/gen/sem_wait.3
+++ b/lib/libc/gen/sem_wait.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 15, 2000
+.Dd April 16, 2013
.Dt SEM_WAIT 3
.Os
.Sh NAME
@@ -75,6 +75,13 @@ points to an invalid semaphore.
.El
.Pp
Additionally,
+.Fn sem_wait
+will fail if:
+.Bl -tag -width Er
+.It Bq Er EINTR
+A signal interrupted this function.
+.El
+Additionally,
.Fn sem_trywait
will fail if:
.Bl -tag -width Er
diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c
index dde474c43e0c..fde33ca567ce 100644
--- a/lib/libc/gen/siginterrupt.c
+++ b/lib/libc/gen/siginterrupt.c
@@ -46,7 +46,7 @@ int
siginterrupt(sig, flag)
int sig, flag;
{
- extern sigset_t _sigintr;
+ extern sigset_t _sigintr __hidden;
struct sigaction sa;
int ret;
diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3
index a41d2589778a..ea6df4410b2c 100644
--- a/lib/libc/gen/signal.3
+++ b/lib/libc/gen/signal.3
@@ -132,6 +132,7 @@ is possible on a descriptor (see
.It 30 Ta Dv SIGUSR1 Ta "terminate process" Ta "User defined signal 1"
.It 31 Ta Dv SIGUSR2 Ta "terminate process" Ta "User defined signal 2"
.It 32 Ta Dv SIGTHR Ta "terminate process" Ta "thread interrupt"
+.It 33 Ta Dv SIGLIBRT Ta "terminate process" Ta "real-time library interrupt"
.El
.Pp
The
diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c
index c93633e23bbb..ee96dcc3c5b6 100644
--- a/lib/libc/gen/signal.c
+++ b/lib/libc/gen/signal.c
@@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "libc_private.h"
-sigset_t _sigintr; /* shared with siginterrupt */
+sigset_t _sigintr __hidden; /* shared with siginterrupt */
sig_t
signal(s, a)
diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3
index 82465b6055e0..d4480beb0e2d 100644
--- a/lib/libc/gen/stringlist.3
+++ b/lib/libc/gen/stringlist.3
@@ -49,7 +49,7 @@
.Ft void
.Fn sl_free "StringList *sl" "int freeall"
.Ft char *
-.Fn sl_find "StringList *sl" "char *item"
+.Fn sl_find "StringList *sl" "const char *item"
.Sh DESCRIPTION
The
.Nm
diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c
index e0db3b675942..a09a8e705e36 100644
--- a/lib/libc/gen/stringlist.c
+++ b/lib/libc/gen/stringlist.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
* sl_init(): Initialize a string list
*/
StringList *
-sl_init()
+sl_init(void)
{
StringList *sl;
@@ -67,9 +67,7 @@ sl_init()
* sl_add(): Add an item to the string list
*/
int
-sl_add(sl, name)
- StringList *sl;
- char *name;
+sl_add(StringList *sl, char *name)
{
if (sl->sl_cur == sl->sl_max - 1) {
sl->sl_max += _SL_CHUNKSIZE;
@@ -86,9 +84,7 @@ sl_add(sl, name)
* sl_free(): Free a stringlist
*/
void
-sl_free(sl, all)
- StringList *sl;
- int all;
+sl_free(StringList *sl, int all)
{
size_t i;
@@ -108,9 +104,7 @@ sl_free(sl, all)
* sl_find(): Find a name in the string list
*/
char *
-sl_find(sl, name)
- StringList *sl;
- char *name;
+sl_find(StringList *sl, const char *name)
{
size_t i;
diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c
index 1edaa5a91154..55e99451b13d 100644
--- a/lib/libc/gen/strtofflags.c
+++ b/lib/libc/gen/strtofflags.c
@@ -62,13 +62,29 @@ static struct {
#endif
{ "nouappnd", 0, UF_APPEND },
{ "nouappend", 0, UF_APPEND },
+ { "nouarch", 0, UF_ARCHIVE },
+ { "nouarchive", 0, UF_ARCHIVE },
+ { "nohidden", 0, UF_HIDDEN },
+ { "nouhidden", 0, UF_HIDDEN },
{ "nouchg", 0, UF_IMMUTABLE },
{ "nouchange", 0, UF_IMMUTABLE },
{ "nouimmutable", 0, UF_IMMUTABLE },
{ "nodump", 1, UF_NODUMP },
- { "noopaque", 0, UF_OPAQUE },
{ "nouunlnk", 0, UF_NOUNLINK },
- { "nouunlink", 0, UF_NOUNLINK }
+ { "nouunlink", 0, UF_NOUNLINK },
+ { "nooffline", 0, UF_OFFLINE },
+ { "nouoffline", 0, UF_OFFLINE },
+ { "noopaque", 0, UF_OPAQUE },
+ { "nordonly", 0, UF_READONLY },
+ { "nourdonly", 0, UF_READONLY },
+ { "noreadonly", 0, UF_READONLY },
+ { "noureadonly", 0, UF_READONLY },
+ { "noreparse", 0, UF_REPARSE },
+ { "noureparse", 0, UF_REPARSE },
+ { "nosparse", 0, UF_SPARSE },
+ { "nousparse", 0, UF_SPARSE },
+ { "nosystem", 0, UF_SYSTEM },
+ { "nousystem", 0, UF_SYSTEM }
};
#define nmappings (sizeof(mapping) / sizeof(mapping[0]))
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index 4af6f821f138..4631aeb6bf1b 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -28,7 +28,7 @@
.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd February 13, 2011
+.Dd April 26, 2013
.Dt SYSCONF 3
.Os
.Sh NAME
@@ -82,7 +82,7 @@ The number of processors configured.
.It Li _SC_NPROCESSORS_ONLN
The number of processors currently online.
.It Li _SC_OPEN_MAX
-The maximum number of open files per user id.
+One more than the maximum value the system may assign to a new file descriptor.
.It Li _SC_PAGESIZE
The size of a system page in bytes.
.It Li _SC_PAGE_SIZE
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index b3737e2d1aaa..7d7b90a7442e 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -28,7 +28,7 @@
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd February 11, 2012
+.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -547,14 +547,14 @@ The length of each message is contained in the message header.
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
-The fifth and sixth level names are as follows:
-.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
-.It Sy "Fifth level name Sixth level is:"
-.It "NET_RT_FLAGS rtflags"
-.It "NET_RT_DUMP None"
-.It "NET_RT_IFLIST 0 or if_index"
-.It "NET_RT_IFMALIST 0 or if_index"
-.It "NET_RT_IFLISTL 0 or if_index"
+The fifth, sixth, and seventh level names are as follows:
+.Bl -column -offset indent "Fifth level Sixth level" "Seventh level"
+.It Sy "Fifth level Sixth level" Ta Sy "Seventh level"
+.It "NET_RT_FLAGS rtflags" Ta "None"
+.It "NET_RT_DUMP None" Ta "None or fib number"
+.It "NET_RT_IFLIST 0 or if_index" Ta None
+.It "NET_RT_IFMALIST 0 or if_index" Ta None
+.It "NET_RT_IFLISTL 0 or if_index" Ta None
.El
.Pp
The
@@ -735,7 +735,6 @@ privilege may change the value.
.It Sy "Second level name Type Changeable"
.It "VM_LOADAVG struct loadavg no"
.It "VM_TOTAL struct vmtotal no"
-.It "VM_PAGEOUT_ALGORITHM integer yes"
.It "VM_SWAPPING_ENABLED integer maybe"
.It "VM_V_CACHE_MAX integer yes"
.It "VM_V_CACHE_MIN integer yes"
@@ -754,9 +753,6 @@ The returned data consists of a
Return the system wide virtual memory statistics.
The returned data consists of a
.Va struct vmtotal .
-.It Li VM_PAGEOUT_ALGORITHM
-0 if the statistics-based page management algorithm is in use
-or 1 if the near-LRU algorithm is in use.
.It Li VM_SWAPPING_ENABLED
1 if process swapping is enabled or 0 if disabled.
This variable is
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index b518b57ae5ea..377caff51cc5 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -121,7 +121,7 @@ we_askshell(const char *words, wordexp_t *we, int flags)
serrno = errno;
- if (pipe(pdes) < 0)
+ if (pipe2(pdes, O_CLOEXEC) < 0)
return (WRDE_NOSPACE); /* XXX */
(void)sigemptyset(&newsigblock);
(void)sigaddset(&newsigblock, SIGCHLD);
@@ -139,25 +139,15 @@ we_askshell(const char *words, wordexp_t *we, int flags)
* We are the child; just get /bin/sh to run the wordexp
* builtin on `words'.
*/
- int devnull;
- char *cmd;
-
(void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
- _close(pdes[0]);
- if (_dup2(pdes[1], STDOUT_FILENO) < 0)
+ if ((pdes[1] != STDOUT_FILENO ?
+ _dup2(pdes[1], STDOUT_FILENO) :
+ _fcntl(pdes[1], F_SETFD, 0)) < 0)
_exit(1);
- _close(pdes[1]);
- if (asprintf(&cmd, "wordexp %s\n", words) < 0)
- _exit(1);
- if ((flags & WRDE_SHOWERR) == 0) {
- if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0)
- _exit(1);
- if (_dup2(devnull, STDERR_FILENO) < 0)
- _exit(1);
- _close(devnull);
- }
execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u",
- "-c", cmd, (char *)NULL);
+ "-c", "eval \"$1\";eval \"wordexp $2\"", "",
+ flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words,
+ (char *)NULL);
_exit(1);
}
@@ -261,7 +251,8 @@ we_check(const char *words, int flags)
while ((c = *words++) != '\0') {
switch (c) {
case '\\':
- quote ^= 1;
+ if (squote == 0)
+ quote ^= 1;
continue;
case '\'':
if (quote + dquote == 0)