Possible fix for --detach crash on some linux systems

Do not use file objects for redirecting the std streams as they could be
garbage collected closing the streams. Also redirect stdin. I dont
really expect either of these to fix the issue, but it's a start.