fix file-handle leakage in non-threaded daemons; #1029