From d6e121064d003f2da072899ca053aabf2a6b0088 Mon Sep 17 00:00:00 2001 From: jilles Date: Fri, 24 May 2013 18:59:44 +0000 Subject: [PATCH] MFC r248593: Allow O_CLOEXEC in posix_openpt() flags. PR: kern/162374 git-svn-id: svn://svn.freebsd.org/base/stable/9@250973 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- lib/libc/sys/posix_openpt.2 | 9 +++++++-- sys/kern/tty_pts.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/libc/sys/posix_openpt.2 b/lib/libc/sys/posix_openpt.2 index 2633847a6..9ba26068a 100644 --- a/lib/libc/sys/posix_openpt.2 +++ b/lib/libc/sys/posix_openpt.2 @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 20, 2008 +.Dd March 21, 2013 .Dt POSIX_OPENPT 2 .Os .Sh NAME @@ -71,7 +71,7 @@ Values for are constructed by a bitwise-inclusive OR of flags from the following list, defined in .In fcntl.h : -.Bl -tag -width ".Dv O_NOCTTY" +.Bl -tag -width ".Dv O_CLOEXEC" .It Dv O_RDWR Open for reading and writing. .It Dv O_NOCTTY @@ -79,6 +79,8 @@ If set .Fn posix_openpt shall not cause the terminal device to become the controlling terminal for the process. +.It Dv O_CLOEXEC +Set the close-on-exec flag for the new file descriptor. .El .Pp The @@ -116,6 +118,9 @@ The .Fn posix_openpt function conforms to .St -p1003.1-2001 . +The ability to use +.Dv O_CLOEXEC +is an extension to the standard. .Sh HISTORY The .Fn posix_openpt diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index d5efed3a5..d6a247793 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -825,10 +825,10 @@ sys_posix_openpt(struct thread *td, struct posix_openpt_args *uap) * POSIX states it's unspecified when other flags are passed. We * don't allow this. */ - if (uap->flags & ~(O_RDWR|O_NOCTTY)) + if (uap->flags & ~(O_RDWR|O_NOCTTY|O_CLOEXEC)) return (EINVAL); - error = falloc(td, &fp, &fd, 0); + error = falloc(td, &fp, &fd, uap->flags); if (error) return (error); -- 2.45.0