Trace filehandles and wd in threads properly