In main(), limit the scope of the variable pid.