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

Page 1 of 1

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

PostPosted: Thu Mar 04, 2010 2:24 am
by xuyong
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?

RE: system("shutdown -q") can

PostPosted: Thu Mar 04, 2010 12:37 pm
by garyritu
Did understand reason behind adding -q. You can directly use system("shutdown") in code. It will shutdown the system.

PostPosted: Thu Mar 04, 2010 2:16 pm
by Tim
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

PostPosted: Fri Mar 05, 2010 12:31 am
by xuyong
I have use system("/bin/shutdown -q"),but it doesn't work,but in another programme it can work.

PostPosted: Fri Mar 05, 2010 3:11 am
by xuyong
the problem have been solved by using sysmgr_reboot()