properly handling terminal resize signal