Unix-system-calls-epoll-ctl

提供:Dev Guides
移動先:案内検索

[top]#

[[File:]]

[[File:]]

|Web |This Site

  • 初心者向けのUnix *
  • 高度なUnix *

選択した読書

Copyright©2014 by finddevguides

  Home     References     Discussion Forums     About TP  

epoll_ctl()-Unix、Linuxシステムコール

[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]

広告

NAME

epoll_ctl-epoll記述子の制御インターフェース

概要

#include <sys/epoll.h> int epoll_ctl(int epfd, int op, int fd, struct epoll_event* event)

説明

ターゲットファイル記述子_fd_に対して操作_op_を実行するように要求することにより、 epoll 記述子_epfd_を制御します。 _event_は、ファイル記述子_fd_にリンクされたオブジェクトを記述します。 _struct epoll_event_は次のように定義されます:

typedef union epoll_data { void *ptr; int fd; __uint32_t u32; __uint64_t u64; } epoll_data_t; struct epoll_event { __uint32_t events; /*Epoll events*/ epoll_data_t data; /*User data variable*/ };

_events_メンバーは、次の利用可能なイベントタイプを使用して構成されたビットセットです。

エラーコード

説明

エポリン

関連ファイルは、* read *(2)操作に使用できます。

*EPOLLOUT*

関連付けられたファイルは、 write (2)操作に使用できます。

*EPOLLRDHUP*

ストリームソケットピアが接続を閉じたか、接続の半分を書き込んでシャットダウンしました。 (このフラグは、Edge Triggered監視を使用しているときにピアのシャットダウンを検出する簡単なコードを書くのに特に役立ちます。)

*EPOLLPRI*
*read* (2)操作に使用できる緊急データがあります。
*EPOLLERR*

関連するファイル記述子でエラー状態が発生しました。 epoll_wait (2)は常にこのイベントを待機します。 _events_で設定する必要はありません。

*EPOLLHUP*

関連付けられたファイル記述子でハングアップしました。 epoll_wait (2)は常にこのイベントを待機します。 _events_で設定する必要はありません。

  • エポレット *

関連付けられたファイル記述子のEdge Triggered動作を設定します。* epoll のデフォルトの動作はLevel Triggeredです。 EdgeおよびLevel Triggeredイベント配布アーキテクチャの詳細については、 *epoll (7)を参照してください。

*EPOLLONESHOT* (カーネル2.6.2以降)

関連するファイル記述子のワンショット動作を設定します。 これは、 epoll_wait (2)でイベントが取り出された後、関連するファイル記述子が内部的に無効になり、 epoll インターフェースによって他のイベントが報告されないことを意味します。 ユーザーは、 EPOLL_CTL_MOD を指定して epoll_ctl (2)を呼び出し、新しいイベントマスクでファイル記述子を再度有効にする必要があります。

*epoll* インターフェースは、 *poll* (2)をサポートするすべてのファイル記述子をサポートします。 _op_パラメータの有効な値は次のとおりです。
Code Description
*EPOLL_CTL_ADD * Add the target file descriptor fd to the* epoll* descriptor epfd and associate the event event with the internal file linked to fd.
EPOLL_CTL_MOD Change the event event associated with the target file descriptor fd.
*EPOLL_CTL_DEL * Remove the target file descriptor fd from the* epoll* file descriptor, epfd. The event is ignored and can be NULL (but see BUGS below).

返り値

成功すると、 epoll_ctl (2)はゼロを返します。 エラーが発生すると、 epoll_ctl (2)は-1を返し、_errno_が適切に設定されます。

エラー

Error Code Description
EBADF epfd or fd is not a valid file descriptor.
EEXIST op was EPOLL_CTL_ADD, and the supplied file descriptor fd is already in epfd.
*EINVAL * epfd is not an* epoll* file descriptor, or fd is the same as epfd, or the requested operation op is not supported by this interface.
ENOENT op was EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not in epfd.
ENOMEM There was insufficient memory to handle the requested op control operation.
*EPERM * The target file fd does not support* epoll*.

準拠

*epoll_ctl* (2)は、Linuxカーネル2.5.44で導入された新しいAPIです。 インターフェイスは、Linuxカーネル2.5.66で確定する必要があります。

BUGS

2.6.9より前のカーネルバージョンでは、 EPOLL_CTL_DEL 操作では、_event_にNULL以外のポインターが必要でしたが、この引数は無視されます。 カーネル2.6.9以降、 EPOLL_CTL_DEL を使用する場合、_event_をNULLとして指定できます。

関連項目

[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]

広告

  
Advertisements