View topic - system("shutdown -q") can't run

system("shutdown -q") can't run

anything that doesn't fit to other groups.

system("shutdown -q") can't run

Postby xuyong » Thu Mar 04, 2010 2:24 am

I can use "shutdown" in terminal windows and let the system reboot,but when I use system("shutdown -q") in one c programme,It does't work and can't get return value,but in another programme it can work,why?
xuyong
Senior Member
 
Posts: 431
Joined: Sun Mar 02, 2003 7:52 am

RE: system("shutdown -q") can

Postby garyritu » Thu Mar 04, 2010 12:37 pm

Did understand reason behind adding -q. You can directly use system("shutdown") in code. It will shutdown the system.
garyritu
Active Member
 
Posts: 58
Joined: Fri May 22, 2009 7:09 am

Postby Tim » Thu Mar 04, 2010 2:16 pm

Xuyong,

Is your program running as root? You can't do a shutdown unless you are a root user.

If your program is running as a root then it may be a path problem. So you might want to specify the exact path system("/bin/shutdown -q")

Tim
Tim
Senior Member
 
Posts: 1469
Joined: Wed Mar 10, 2004 12:28 am

Postby xuyong » Fri Mar 05, 2010 12:31 am

I have use system("/bin/shutdown -q"),but it doesn't work,but in another programme it can work.
xuyong
Senior Member
 
Posts: 431
Joined: Sun Mar 02, 2003 7:52 am

Postby xuyong » Fri Mar 05, 2010 3:11 am

the problem have been solved by using sysmgr_reboot()
xuyong
Senior Member
 
Posts: 431
Joined: Sun Mar 02, 2003 7:52 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 2 guests