Adds thread locking to protect MapScript's acquisition of the stdout stream. Previously caused seg fault