terminal control and signal handling