I would not advise trying to do this in user space. Do it the right way to begin with, as a kernel module/component.
Check out these bits of documentation in the Linux source tree if you haven't already:
Documentation/power/devices.txt
Documentation/gpio.txt
Essentially, you need to:
- Register the input gpio
- Register an ISR for that GPIO via gpio_to_irq() and request_irq().
- Build out the power management operations as discussed in the above documentation.
- Arrange for yoru power management hooks to be called from the interrupt service routine