PMCREATEATTACHFD(3) | PMCREATEATTACHFD(3) |
int pmCreateAttachFd(pmContext *pmc, int *fdp);
pmContext * |
pmc |
pmContext object |
|
int * |
fdp |
File descriptor for pmAttachContext () |
pmCreateAttachFd
() creates a new file descriptor which will
be passed to pmAttachContext().
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.
PM_SUCCESS |
Success |
EMFILE |
Too many descriptors are active |
waitpid
(2) to avoid simultaneous access:
Call this function from the parent process to access theif ((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
sequentially:
pmCreateAttachFd(pmc, &fd); if ((pid = fork()) == 0) { invoke application by exec(2). _exit(1); }