Like Linux, OS X is designed not to require restarting. There is no system wide means to determine if a restart is required - or even requested by a process.
For situations where a restart is required, the process responsible for needing the restart is also responsible for organising the restart.
Tools that update OS X are most likely to request a restart.
Take a look at the
softwareupdate manual page for the most likely candidate to request a restart.
softwareupdate prints a message at the end of the updating process stating if a restart is required. The calling script or user is then responsible for restarting.
If an update requires a restart to be successfully and safely installed, OS X will delay the updating process. The update will wait until the next restart or shut down.
This approach allows updates to be downloaded as part of a schedule but not interrupt or interfere with running processes or active users.
To see if an update is pending, check the contents of
/Library/Updates/. This folder appears to contain property list files documenting packages and updates queued for installation.
You can use the tool
defaults in your scripts to read
plist files such as
defaults read /Library/Updates/index.plist InstallAtLogout