Checks if shm and sem are created before executing write