Refactor whoami.c

use err_exit