Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reboot?

Status
Not open for further replies.

bardley

Programmer
May 8, 2001
121
0
0
US
Is it possible/advisable to cause a linux system to reboot from inside a c++ program?

Are there other (perhaps more stable) methods of doing this?

Brad Gunsalus
bardley90@hotmail.com
 
I assume you mean get your program to invoke the 'shutdown' command.

This is the most organised and cleanest way of rebooting the system. Users have a chance to save their work and programs can exit cleanly by properly closing files.

The shutdown command can send a message explaining why, and also provide a delay to allow people to react accordingly.

--
 
See also InitiateSystemShutdown() and/or ExitWindowsEx() Win API (and related OpenProcessToken(), LookupPrivilegeValue(), AdjustTokenPrivileges() etc) in MSDN. There are some programmatic shutdown codes examples in C. Your application must have corresponding privileges (to adjust privileges;)...
 
Oh, I'm sorry: it's Unix forum!...
Sorry...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top