Deleted Added
full compact
fcntl.2 (165903) fcntl.2 (176957)
1.\" Copyright (c) 1983, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 12 unchanged lines hidden (view full) ---

21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
1.\" Copyright (c) 1983, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.

--- 12 unchanged lines hidden (view full) ---

21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
29.\" $FreeBSD: head/lib/libc/sys/fcntl.2 165903 2007-01-09 00:28:16Z imp $
29.\" $FreeBSD: head/lib/libc/sys/fcntl.2 176957 2008-03-08 22:02:21Z antoine $
30.\"
30.\"
31.Dd January 12, 1994
31.Dd March 8, 2008
32.Dt FCNTL 2
33.Os
34.Sh NAME
35.Nm fcntl
36.Nd file control
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS

--- 33 unchanged lines hidden (view full) ---

73Same file status flags (i.e., both file descriptors
74share the same file status flags).
75.It
76The close-on-exec flag associated with the new file descriptor
77is set to remain open across
78.Xr execve 2
79system calls.
80.El
32.Dt FCNTL 2
33.Os
34.Sh NAME
35.Nm fcntl
36.Nd file control
37.Sh LIBRARY
38.Lb libc
39.Sh SYNOPSIS

--- 33 unchanged lines hidden (view full) ---

73Same file status flags (i.e., both file descriptors
74share the same file status flags).
75.It
76The close-on-exec flag associated with the new file descriptor
77is set to remain open across
78.Xr execve 2
79system calls.
80.El
81.It Dv F_DUP2FD
82It is functionally equivalent to
83.Bd -literal -offset indent
84dup2(fd, arg)
85.Ed
86.Pp
87The
88.Dv F_DUP2FD
89constant is not portable, so it should not be used if portability is needed.
90Use
91.Fn dup2
92instead.
81.It Dv F_GETFD
82Get the close-on-exec flag associated with the file descriptor
83.Fa fd
84as
85.Dv FD_CLOEXEC .
86If the returned value ANDed with
87.Dv FD_CLOEXEC
88is 0,

--- 295 unchanged lines hidden (view full) ---

384error.
385.Sh RETURN VALUES
386Upon successful completion, the value returned depends on
387.Fa cmd
388as follows:
389.Bl -tag -width F_GETOWNX -offset indent
390.It Dv F_DUPFD
391A new file descriptor.
93.It Dv F_GETFD
94Get the close-on-exec flag associated with the file descriptor
95.Fa fd
96as
97.Dv FD_CLOEXEC .
98If the returned value ANDed with
99.Dv FD_CLOEXEC
100is 0,

--- 295 unchanged lines hidden (view full) ---

396error.
397.Sh RETURN VALUES
398Upon successful completion, the value returned depends on
399.Fa cmd
400as follows:
401.Bl -tag -width F_GETOWNX -offset indent
402.It Dv F_DUPFD
403A new file descriptor.
404.It Dv F_DUP2FD
405A file descriptor equal to
406.Fa arg .
392.It Dv F_GETFD
393Value of flag (only the low-order bit is defined).
394.It Dv F_GETFL
395Value of flags.
396.It Dv F_GETOWN
397Value of file descriptor owner.
398.It other
399Value other than -1.

--- 27 unchanged lines hidden (view full) ---

427The
428.Fa fd
429argument
430is not a valid open file descriptor.
431.Pp
432The argument
433.Fa cmd
434is
407.It Dv F_GETFD
408Value of flag (only the low-order bit is defined).
409.It Dv F_GETFL
410Value of flags.
411.It Dv F_GETOWN
412Value of file descriptor owner.
413.It other
414Value other than -1.

--- 27 unchanged lines hidden (view full) ---

442The
443.Fa fd
444argument
445is not a valid open file descriptor.
446.Pp
447The argument
448.Fa cmd
449is
450.Dv F_DUP2FD ,
451and
452.Fa arg
453is not a valid file descriptor.
454.Pp
455The argument
456.Fa cmd
457is
435.Dv F_SETLK
436or
437.Dv F_SETLKW ,
438the type of lock
439.Pq Fa l_type
440is a shared lock
441.Pq Dv F_RDLCK ,
442and

--- 47 unchanged lines hidden (view full) ---

490and the data to which
491.Fa arg
492points is not valid.
493.It Bq Er EMFILE
494The argument
495.Fa cmd
496is
497.Dv F_DUPFD
458.Dv F_SETLK
459or
460.Dv F_SETLKW ,
461the type of lock
462.Pq Fa l_type
463is a shared lock
464.Pq Dv F_RDLCK ,
465and

--- 47 unchanged lines hidden (view full) ---

513and the data to which
514.Fa arg
515points is not valid.
516.It Bq Er EMFILE
517The argument
518.Fa cmd
519is
520.Dv F_DUPFD
521or
522.Dv F_DUP2FD
498and the maximum number of file descriptors permitted for the
499process are already in use,
500or no file descriptors greater than or equal to
501.Fa arg
502are available.
503.It Bq Er ENOLCK
504The argument
505.Fa cmd

--- 56 unchanged lines hidden (view full) ---

562and a
563.Fa cmd
564of
565.Dv F_GETOWN
566for the reasons as stated in
567.Xr tcgetpgrp 3 .
568.Sh SEE ALSO
569.Xr close 2 ,
523and the maximum number of file descriptors permitted for the
524process are already in use,
525or no file descriptors greater than or equal to
526.Fa arg
527are available.
528.It Bq Er ENOLCK
529The argument
530.Fa cmd

--- 56 unchanged lines hidden (view full) ---

587and a
588.Fa cmd
589of
590.Dv F_GETOWN
591for the reasons as stated in
592.Xr tcgetpgrp 3 .
593.Sh SEE ALSO
594.Xr close 2 ,
595.Xr dup2 2 ,
570.Xr execve 2 ,
571.Xr flock 2 ,
572.Xr getdtablesize 2 ,
573.Xr open 2 ,
574.Xr sigvec 2 ,
575.Xr lockf 3 ,
576.Xr tcgetpgrp 3 ,
577.Xr tcsetpgrp 3
596.Xr execve 2 ,
597.Xr flock 2 ,
598.Xr getdtablesize 2 ,
599.Xr open 2 ,
600.Xr sigvec 2 ,
601.Xr lockf 3 ,
602.Xr tcgetpgrp 3 ,
603.Xr tcsetpgrp 3
604.Sh STANDARDS
605The
606.Dv F_DUP2FD
607constant is non portable.
608It is provided for compatibility with AIX and Solaris.
578.Sh HISTORY
579The
580.Fn fcntl
581system call appeared in
582.Bx 4.2 .
609.Sh HISTORY
610The
611.Fn fcntl
612system call appeared in
613.Bx 4.2 .
614.Pp
615The
616.Dv F_DUP2FD
617constant first appeared in
618.Fx 7.1 .