Install a file-descriptor function
int PtAppAddFd( PtAppContext_t app, int fd, unsigned mode, PtFdProc_t fun, void *data); int PtAppAddFdPri( PtAppContext_t app, int fd, unsigned mode, PtFdProc_t fun, void *data, int priority);
These values correspond to conditions defined for the ionotify() or select() functions. You can OR two or all three values together. You can change the mode later by calling PtAppSetFdMode().
typedef int PtFdProcF_t( int fd, void *data, unsigned mode ); typedef PtFdProcF_t *PtFdProc_t;
The fd and data arguments have the same value as the fd and data arguments to PtAppAddFd(). The mode argument indicates which conditions were actually met.
The fun function should return Pt_CONTINUE to remain on the list of fd functions, or Pt_END to be removed automatically from it.
These functions install an “FD function” that informs the application about device events.
If your application needs to perform I/O such as reading from or writing to a pipe, you should add an FD handler. An FD handler is a function that's called by the main event loop when a given file descriptor (FD) is ready for input or output.
Multiple FD functions attached to the same file descriptor aren't supported. PtAppAddFd() fails with errno set to EBUSY if you try to attach another function to the same FD.
PtAppCreatePulse(), PtAppRemoveFd(), PtAppSetFdMode(), PtFdProc_t
“Other I/O mechanisms” in the Interprocess Communication chapter of the Photon Programmer's Guide