separate unix-related codes to make Swarm buildable on Windows

Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>