PMCREATEATTACHFD(3)
PM Programmer's Manual
PMCREATEATTACHFD(3)
NAME
pmCreateAttachFd - create a new file descriptor

SYNOPSIS
int pmCreateAttachFd(pmContext *pmc, int *fdp);

ARGUMENTS
pmContext * pmc
IN
pmContext object
int * fdp
OUT
File descriptor for pmAttachContext()

IMPLEMENTATION LEVEL
BASE

DESCRIPTION
pmCreateAttachFd() creates a new file descriptor which will be passed to pmAttachContext().

NOTES
The pmContext passed to this function should not be accessed by other processes while this function is running. This function should be used as in the following examples.

RETURN VALUES
PM_SUCCESS Success
EMFILE Too many descriptors are active

EXAMPLES
Use waitpid(2) to avoid simultaneous access:
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);
Call this function from the parent process to access the pmContext sequentially:
pmCreateAttachFd(pmc, &fd);
if ((pid = fork()) == 0) {
    invoke application by exec(2).
    _exit(1);
}


$Id: pmCreateAttachFd.html,v 1.1.1.1 2002/02/12 02:00:13 kameyama Exp $