PMCREATEATTACHFD(3) | PMCREATEATTACHFD(3) |
int pmCreateAttachFd(pmContext *pmc, int *fdp);
pmContext * |
pmc |
pmContext オブジェクト |
|
int * |
fdp |
pmAttachContext () で使われるファイル デスクリプタ |
pmCreateAttachFd
() は pmAttachContext() に渡される新しいファイル デスクリプタを生成します。
pmContext
にアクセスしてはいけません。
この関数は以下の例のように使わなければなりません。
PM_SUCCESS |
成功 |
EMFILE |
アクティブなデスクリプタが多すぎます。 |
waitpid
(2) を用いて同時アクセスを回避:
親プロセスからこの関数を呼び出し、if ((pid = fork()) == 0) { error = pmCreateAttachFd(pmc, &fd); kill(getpid(), SIGSTOP); /* tell OK to access pmc */ invoke application by exec(2). _exit(1); } waitpid(pid, &stat, WUNTRACED); /* wait until it's OK */ kill(pid, SIGCONT);
pmContext
に逐次的にアクセス。
pmCreateAttachFd(pmc, &fd); if ((pid = fork()) == 0) { invoke application by exec(2). _exit(1); }