Even better, do:
sudo softwareupdate -ia && sudo reboot
The reboot will then only happen if the first command succeeds. If it fails the reboot won’t happen and you’ll be able to see the errors.
Edit: Even even better:
sudo sh -c “softwareupdate -ia && reboot”
With my first example, if the software update takes a long-ish time, the timeout for sudo asking for a password will expire, and the sudo reboot will sit waiting for your password.
The 2nd version wraps both commands into a mini shell script, with a single sudo, so there’s no second sudo to possibly time out.