![]() |
![]() |
![]() |
![]() |
This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs. |
Obtain a handle to a power managed object
#include <sys/pm.h> #include <fcnl.h> pm_hdl_t pm_attach(const char *name, int flags);
libpm
The pm_attach() obtains a handle allowing a client to manipulate a power managed object.
The flags argument specifies the required access:
An opaque handle that can be used to manipulate the object.
The pm_valid_hdl() function can be used to check if the handle is valid. If pm_attach() is unsuccessful, errno is set to indicate the error.
#include <sys/pm.h> #include <fcntl.h> #include <stdlib.h>
int main() { pm_hdl_t hdl; // attach to object with read-only access hdl = pm_attach("object", O_RDONLY); if (!pm_valid_hdl(hdl)) { perror("pm_attach"); return EXIT_FAILURE; } if (pm_detach(hdl) == -1) { perror("pm_detach"); return EXIT_FAILURE; } // attach to object with read-write access hdl = pm_attach("object", O_RDWR); if (!pm_valid_hdl(hdl)) { perror("pm_attach"); return EXIT_FAILURE; } return EXIT_SUCCESS; }
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
![]() |
![]() |
![]() |