fcntl

Section: System Calls (2)
Updated: 2026-02-08
Index JM Home Page roff page
 

名前

fcntl - ファイルディスクリプターの操作を行う  

ライブラリ

標準 C ライブラリ (libc,~-lc)  

書式

#include <fcntl.h>

int fcntl(int fd, int op, ...);
 

説明

fcntl() performs one of the operations described below on the open file descriptor fd. The operation is determined by op.

Certain of the operations below are supported only since a particular Linux kernel version. The preferred method of checking whether the host kernel supports a particular operation is to invoke fcntl() with the desired op value and then test whether the call failed with EINVAL, indicating that the kernel does not recognize this value.  

ファイルディスクリプターの複製

F_DUPFD(2const)
F_DUPFD_CLOEXEC(2const)
 

ファイルディスクリプターフラグ

F_GETFD(2const)
F_SETFD(2const)
 

ファイル状態フラグ

F_GETFL(2const)
F_SETFL(2const)
 

アドバイザリーレコードロック

F_SETLK(2const)
F_SETLKW(2const)
F_GETLK(2const)
 

オープンファイル記述ロック (非 POSIX)

F_OFD_SETLK(2const)
F_OFD_SETLKW(2const)
F_OFD_GETLK(2const)
 

シグナルの管理

F_GETOWN(2const)
F_SETOWN(2const)
F_GETOWN_EX(2const)
F_SETOWN_EX(2const)
F_GETSIG(2const)
F_SETSIG(2const)
 

リース (leases)

F_SETLEASE(2const)
F_GETLEASE(2const)
 

Delegations

F_SETDELEG(2const)
F_GETDELEG(2const)
 

ファイルやディレクトリの変更の通知 (dnotify)

F_NOTIFY(2const)
 

パイプの容量の変更

F_SETPIPE_SZ(2const)
F_GETPIPE_SZ(2const)
 

File Sealing

F_ADD_SEALS(2const)
F_GET_SEALS(2const)
 

File read/write hints

F_GET_RW_HINT(2const)
F_SET_RW_HINT(2const)
F_GET_FILE_RW_HINT(2const)
F_SET_FILE_RW_HINT(2const)
 

返り値

For a successful call, the return value depends on the operation.

エラーの時は -1 が返され、 errno はエラーを示すために設定される。  

エラー

EACCES か EAGAIN
他のプロセスが保持しているロックによって操作が禁止されている。
EAGAIN
そのファイルは他のプロセスによってメモリーマップされているため、 操作が禁止されている。
EBADF
fd がオープンされたファイルディスクリプターではない。
EINVAL
The value specified in op is not recognized by this kernel.
 

バージョン

POSIX.1-2024 specifies FD_CLOFORK and F_DUPFD_CLOFORK, but Linux doesn't support them.  

標準規格

POSIX.1-2024.  

歴史

4.3BSD, SVr4, POSIX.1-1988.  

関連項目


 dup2(2), flock(2), open(2), socket(2), lockf(3), capabilities(7), feature_test_macros(7), lslocks(8)


 

Index

名前
ライブラリ
書式
説明
ファイルディスクリプターの複製
ファイルディスクリプターフラグ
ファイル状態フラグ
アドバイザリーレコードロック
オープンファイル記述ロック (非 POSIX)
シグナルの管理
リース (leases)
Delegations
ファイルやディレクトリの変更の通知 (dnotify)
パイプの容量の変更
File Sealing
File read/write hints
返り値
エラー
バージョン
標準規格
歴史
関連項目

This document was created by man2html, using the manual pages.