Merge pull request #1746 from rubenk/swrite-check-for-open-fd