unistd added to viewer_state.cpp