From fbc11ba16451406531ec1e4041b4c329295283a7 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Tue, 9 May 2006 00:41:22 +0000 Subject: [PATCH] (Ports and File Descriptors): Tweaks to fcntl. --- doc/ref/posix.texi | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 31cb948ef..b7ec2998e 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -472,10 +472,11 @@ If @var{size} is omitted, a default size will be used. @end defvar @end deffn -@deffn {Scheme Procedure} fcntl object cmd [value] +@deffn {Scheme Procedure} fcntl port/fd cmd [value] @deffnx {C Function} scm_fcntl (object, cmd, value) -Apply @var{cmd} on @var{object}, either a port or file descriptor. -The @var{value} is an integer argument, for the @code{SET} commands. +Apply @var{cmd} on @var{port/fd}, either a port or file descriptor. +The @var{value} argument is used by the @code{SET} commands described +below, it's an integer value. Values for @var{cmd} are: @@ -497,6 +498,13 @@ flag, @example (fcntl port F_SETFD FD_CLOEXEC) @end example + +Or better, set it but leave any other possible future flags unchanged, + +@example +(fcntl port F_SETFD (logior FD_CLOEXEC + (fcntl port F_GETFD))) +@end example @end defvar @end defvar @@ -509,8 +517,8 @@ A common use is to set @code{O_NONBLOCK} on a network socket. The following sets that flag, and leaves other flags unchanged. @example -(fcntl sock F_SETFL - (logior (fcntl sock F_GETFL) O_NONBLOCK)) +(fcntl sock F_SETFL (logior O_NONBLOCK + (fcntl sock F_GETFL))) @end example @end defvar