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 176957 2008-03-08 22:02:21Z antoine $ |
30.\" |
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 |
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. |
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 . |
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 |
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 |
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 , |
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. |
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 . |