daemon: Log output from state hooks to a file.
daemon: Log output from state hooks to a file.

Also close other file descriptors when running state hooks.

coreemu/core,coreemu/core,coreemu/core,coreemu/core