added handlers for sigint and sigterm as well as closed stdin