LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-07-2011, 04:36 PM   #1
drb
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");
or
sync();
reboot(LINUX_REBOOT_CMD_RESTART);
or
system("reboot");

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?

Thanks,

drb
 
Old 07-07-2011, 04:49 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Code:
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).


Cheers,
Tink
 
Old 07-07-2011, 06:38 PM   #3
drb
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, 06:57 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

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

See also the links at the bottom of that page eg http://linux.die.net/man/8/reboot
 
Old 07-07-2011, 07:06 PM   #5
drb
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,

drb
 
  


Reply


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 04:24 AM
LXer: Force a clean reboot when the system freezes LXer Syndicated Linux News 0 11-24-2008 12:50 PM
force file system integrity check on reboot paul_mat Linux - Software 1 05-30-2006 09:02 PM
How can i force a program to use esdplay? npc Linux - Software 2 08-05-2005 06:07 PM
Intermittent disconnects force reboot (RH8) NLawrence Linux - Networking 0 02-28-2004 01:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:49 AM.

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