Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-07-2011, 05:36 PM   #1
LQ Newbie
Registered: May 2011
Posts: 14

Rep: Reputation: Disabled
Question Can't force reboot from program

Hi all,

I'm running Linux release 2.4.19-uc0, build #511 embedded on a device. It is stripped down to a very minimal configuration and so many of the normal commands are not present.

I'm trying to force a reboot from an application I've got running. I've tried the following:

system("shutdown -r");

but all leave the device in a limbo state where I can't get to it with any networking tools, but it also does not reboot. I can issue the "shutdown -r" and the "reboot" commands from a Telnet session and they work fine.

Any thoughts?


Old 07-07-2011, 05:49 PM   #2
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
1.) Try specifying the full path.
2.) Consider using a member of the exec family instead of system
    System will try to wait for "shutdown" to complete (whatever the
    result of that may be).

Old 07-07-2011, 07:38 PM   #3
LQ Newbie
Registered: May 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
I was trying to use the execl() function, but I noticed that shutdown is not in either /bin or /sbin and in fact I don't know where it is but I know I can execute it from Telnet. Any ideas how I would want to set up the execl() to work?

Sorry, I'm not very fluent in linux :-(

Thanks for any assistance you can give.
Old 07-07-2011, 07:57 PM   #4
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Well, normally it's in /sbin and would normally be called thus
/sbin/shutdown -r now
ie shutdown & reboot & do it now/immediately..
If it's not there, you can see where it is by using
which shutdown
at the cmd line

See also the links at the bottom of that page eg
Old 07-07-2011, 08:06 PM   #5
LQ Newbie
Registered: May 2011
Posts: 14

Original Poster
Rep: Reputation: Disabled
more info.

I can see the source code for a sash.c which I assume is eventually made into sh and in that code, it can parse out a bunch of commands that are not listed in /bin or /sbin (including shutdown and reboot). Perhaps this is the shell used during telnet, but I can't seem to call it from the application. I'm unclear on how to proceed.

Thanks in advance,



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make libata.force=1.5G work without reboot? sscn Linux - Software 2 06-07-2011 05:24 AM
LXer: Force a clean reboot when the system freezes LXer Syndicated Linux News 0 11-24-2008 01:50 PM
force file system integrity check on reboot paul_mat Linux - Software 1 05-30-2006 10:02 PM
How can i force a program to use esdplay? npc Linux - Software 2 08-05-2005 07:07 PM
Intermittent disconnects force reboot (RH8) NLawrence Linux - Networking 0 02-28-2004 02:29 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:28 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration