-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Stop-Computer, Restart-Computer on macOS: support graceful shutdown by default, implement -Force support #19791
Copy link
Copy link
Open
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeThe bot will ignore these and not auto-closeUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management moduleWG-ReviewedA Working Group has reviewed this and made a recommendationA Working Group has reviewed this and made a recommendation
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
Reviewed
Summary of the new feature / enhancement
Note:
This would not be a breaking change, because
Stop-ComputerandRestart-Computerare currently broken altogether on macOS - see Stop-Computer: broken on macOS; suboptimal UX on all Unix-like platforms #19738I do not know enough about Linux distros to tell if a distinction analogous to the one below is even possible or necessary there. Perhaps the answers here provide clues.
A fix for #19738 is being worked on in #19780, and it will delegate to
/sbin/shutdown -h now(shutdown) and/sbin/shutdown -r now(reboot) on macOS.However, these commands amount to a forced shutdown: they do not afford GUI applications enough time to shut down gracefully, such as browsers and VM software, inducing potential data loss.
Therefore, I propose the following:
Proposed technical implementation details (optional)
By default, use the following commands on macOS - they do shut down gracefully, but - as on Windows - do not guarantee a shutdown, if an app refuses to quit:
osascript -e 'tell application "System Events" to shut down'osascript -e 'tell application "System Events" to restart'Use
/sbin/shutdownONLY if-Forceis specified./sbin/shutdown -h now/sbin/shutdown -r nowNote that the "graceful" commands do not require
sudo, i.e. administrative privileges, whereas/sbin/shutdownalways does.