Fix stderr redirect platform issues

.. don't use toLatin1() and fopen, use QFile and full QStrings
   so we can support directory names with unicode characters.

.. add unistd.h for dup() and close()