What is the difference between shutdown command and doing shutdown from apple menu?

Solution 1:

From the shutdown man page:

 Upon shutdown, all running processes are sent a SIGTERM followed by a
 SIGKILL.  The SIGKILL will follow the SIGTERM by an intentionally inde-
 terminate period of time.  Programs are expected to take only enough time
 to flush all dirty data and exit.  Developers are encouraged to file a
 bug with the OS vendor, should they encounter an issue with this func-
 tionality.

So from what I understand, processes may be killed before they have properly cleaned up.


From the launchctl man page:

  reboot [system|userspace|halt|logout|apps|reroot <mount-point>]
              Instructs launchd to begin tearing down userspace. With no argu-
              ment given or with the system argument given, launchd will make
              the reboot(2) system call when userspace has been completely
              torn down. With the halt argument given, launchd will make the
              reboot(2) system call when userspace has been completely torn
              down and pass the RB_HALT flag, halting the system and not ini-
              tiating a reboot.

This is what I think shutting down via the menu does, it is better as it ensures that all userland processes are exited cleanly before halting/rebooting the system.


I would be tempted to say that the launchctl method is better, and the shutdown -h now method could possibly result in some oddities should a process be killed before properly cleaning itself up.