ruby client: extract common signal handler codes as methods