Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fcntl(2) — DG/UX 4.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought



                                                                 fcntl(2)



        _________________________________________________________________
        fcntl                                                 System Call
        File descriptor control.
        _________________________________________________________________


        SYNTAX

        #include <fcntl.h>

        int   fcntl  (fildes, command, argument)
        int             fildes;
        int             command;
        int             argument;


        PARAMETERS

        fildes         A valid, active file descriptor.


        command        A file control command.


        argument       An argument.  Used only if <command> is F_DUPFD,
                       F_SETFD, F_SETOWN, F_SETFL, F_SETLK, F_SETLKW, or
                       F_GETLK.


        DESCRIPTION

        Fcntl provides a variety of operations on descriptors. <Fildes>
        is an active, valid descriptor.  <Command> is a file control
        command to be performed on <fildes> using <argument> as an
        argument.  Not all commands require an argument.  The commands
        available are:


        F_DUPFD
             The first (lowest numbered) inactive descriptor of the
             calling process, greater than or equal to <argument>, is
             made a duplicate of <fildes>.  Thus, both descriptors refer
             to the same object pointer.  The new descriptor's 'close-
             on-exec' attribute is set to remain open across exec
             operations.

        This operation is equivalent to dup if <argument> is zero and
        dup2 if <argument> is an inactive descriptor.

        This operation does not extend beyond the boundaries of the I/O
        subsystem.  Thus, the type manager of the object to which



        DG/UX 4.00                                                 Page 1
               Licensed material--property of copyright holder(s)





                                                                 fcntl(2)



        <fildes> refers is not informed of the additional reference to
        that object.


        F_SETFD
             Set the `close-on-exec' attribute of <fildes> to the low-
             order bit of <argument>.  If the low-order bit is 0, the
             file will remain open across exec operations; otherwise, the
             file will be closed upon execution of the exec operation.


        F_GETFD
             Return the `close-on-exec' attribute of <fildes>.


        F_SETOWN
             Invoke the type manager of the object to which <fildes>
             refers to set the process id or process group id receiving
             the SIGIO and SIGURG signals for the object.  Process group
             ids are specified by supplying <argument> as negative,
             otherwise <argument> is interpreted as a process id.


        F_GETOWN
             Query the type manager of the object to which <fildes>
             refers for the process id or process group id currently
             receiving SIGIO and SIGURG signals for the object. Process
             group ids are returned as negative values.


        F_SETFL
             Invoke the type manager of the object to which <fildes>
             refers to set the object pointer status flag bits to
             <argument>.  Only the following flag bits may be set:
             O_NONBLOCK, O_NDELAY, O_APPEND, O_SYNC, and O_ASYNC.


        F_GETFL
             Query the type manager of the object to which <fildes>
             refers for the object pointer status flag. The following
             flags will be returned if set in the object pointer status
             flag:  O_NONBLOCK, O_NDELAY, O_APPEND, O_SYNC, O_ASYNC,
             O_RDWR, O_RDONLY, and O_WRONLY.


        F_SETLK
             Set or clear a file lock according to <argument>, which is
             interpreted to be a struct flock.  F_SETLK is used to set
             read locks, set write locks, or remove either type of lock.
             If a read or a write lock cannot be set, fcntl will return
             immediately with a value of -1.



        DG/UX 4.00                                                 Page 2
               Licensed material--property of copyright holder(s)





                                                                 fcntl(2)



        F_SETLKW
             This command is the same as F_SETLK except if a read or
             write lock is blocked by other locks, the process will pend
             until the segment to be locked is free.


        F_GETLK
             Get the first lock that blocks the lock description
             specified by <argument>, which is interpreted to be a struct
             flock.  The information retrieved overwrites the information
             passed to fcntl in <argument>.  If no lock is found that
             would prevent this lock from being set, then <argument> is
             unchanged, except for the lock type, which is set to
             F_UNLCK.

        ACCESS CONTROL

        None.


        RETURN VALUE

        The value returned may be one of the following regardless of the
        value of <command>:


        -1             An error occurred.  Errno is set to indicate the
                       error.

        If <command> is F_GETFD, the value returned may be one of the
        following:


        0 or 1         Completed successfully. The value of the close-
                       on-exec flag is returned.

        If <command> is F_SETFD, F_SETFL or F_SETOWN, the value returned
        may be one of the following:


        0              Completed successfully.

        If <command> is F_DUPFD, the value returned may be one of the
        following:


        <argument>..<NOFILE-1>
                       Completed successfully. A new file descriptor is
                       returned.

        If <command> is F_GETOWN, the value returned may be one of the



        DG/UX 4.00                                                 Page 3
               Licensed material--property of copyright holder(s)





                                                                 fcntl(2)



        following:


        <owner>        Completed successfully. If the value is negative,
                       -<owner> is the process group id returned.
                       Otherwise <owner> is a process id.  Note that the
                       process group may be 1 in which case, -1 will be
                       returned.

        If <command> is F_GETFL, the value returned may be one of the
        following:


        <file_flags>   Completed successfully. The value of the file
                       flags is returned.

        If <command> is F_GETLK, F_SETLK, or F_SETLKW, the value returned
        may be the following:


        0              Completed successfully.


        EXCEPTIONS

        Errno may be set to one of the following error codes regardless
        of the value of <command>:


        EBADF          <Fildes> is not a valid, active descriptor.


        EINVAL         <Command> is not one of the known values.

        If <command> is F_DUPFD, errno may be set to one of these values:


        EMFILE         All descriptors are currently open.


        EINVAL         <Argument> is not a valid descriptor.

        If <command> is F_SETLK, F_SETLKW, or F_GETLK, errno may be set
        to one of these values:


        EINVAL         The flock structure pointed to by <argument> is
                       outside the process's readable address space.


        EBADF          The caller requested a read lock, and the channel



        DG/UX 4.00                                                 Page 4
               Licensed material--property of copyright holder(s)





                                                                 fcntl(2)



                       does not provide read access, or the caller
                       requested a write lock and the channel does not
                       provide write access.


        EINTR          The command was F_SETLKW and the process was
                       interrupted while pending on a lock.


        EDEADLK        The command was F_SETLKW and a deadlock would
                       exist if the lock were granted.


        EACCES         The command was F_SETLK and the type of lock
                       sought is a read lock (F_RDLCK) or write lock
                       (F_WRLCK), and the segment of a file to be locked
                       is already write-locked by another process, or the
                       type is a write lock and the segment of a file to
                       be locked is already read-locked or write-locked
                       by another process.

        Additional errors may be given by the type managers.


        SEE ALSO

        The related manual sections:  creat(2), close(2), dup(2),
        dup2(2), exec(2), fork(2), getdtablesize(2), open(2), pipe(2),
        sigvec(2), socket(2), socketpair(2),
        fcntl(5).
























        DG/UX 4.00                                                 Page 5
               Licensed material--property of copyright holder(s)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026