Fixed a few bugs and refactored privileged helper so that file descriptor is passed back.
Fixed a few bugs and refactored privileged helper so that file descriptor is passed back.

pandazheng/HexFiend,saulogt/HexFiend,thx0701/HexFiend,saulogt/HexFiend,thx0701/HexFiend,thx0701/HexFiend,kedh/HexFiend,pandazheng/HexFiend,saulogt/HexFiend,kedh/HexFiend,thx0701/HexFiend,kedh/HexFiend,kedh/HexFiend,pandazheng/HexFiend,saulogt/HexFiend,pandazheng/HexFiend