LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-09-2010, 01:56 AM   #1
ploceus
LQ Newbie
 
Registered: Jul 2007
Posts: 4

Rep: Reputation: 0
init.d process does not return to prompt.


Hi.

I have a script in /etc/rc.d/init.d named foo. I want to start/stop/restart my process as follows:

$ foo start

But I do not see the [OK] message once it starts. There is no shell prompt returned either. It seems that my own process is the problem.

The executable that foo calls is built from this sample code:

int main()
{
do {
printf("Hello world\n");
sleep(1);
} while (1);
}

Do I have to return some kind of signal handle for this to work?

Thanks for any help.
 
Old 07-09-2010, 02:34 AM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 97
What's content of your foo script?

Last edited by troop; 07-09-2010 at 02:37 AM.
 
Old 07-09-2010, 03:07 AM   #3
salous
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
It won't return because your program is stuck in a infinite loop.

Last edited by salous; 07-09-2010 at 03:15 AM. Reason: typo
 
Old 07-09-2010, 07:21 AM   #4
ploceus
LQ Newbie
 
Registered: Jul 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Content of sample init.d script foo

Quote:
Originally Posted by troop View Post
What's content of your foo script?

Hi, the content is:

--------------------
#!/bin/sh

. /etc/rc.d/init.d/functions

case "$1" in
start)
echo -n "Starting foo: "
daemon /home/ju/foo
echo
touch /var/lock/subsys/foo
;;
stop)
echo -n "Shutting down foo: "
killproc /home/ju/foo
echo
rm -f /var/lock/subsys/foo
rm -f /var/run/foo.pid
;;
status)
status foo
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0
 
Old 07-09-2010, 07:32 AM   #5
ploceus
LQ Newbie
 
Registered: Jul 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by salous View Post
It won't return because your program is stuck in a infinite loop.

Yes, but servers also run in infinite loop, waiting for something, like incoming messages, waiting for other processes? How are those applications able to run forever and still able to get prompt back?

example:
# ./network restart
Shutting down interface eth0: [OK]
Shutting down loopback interface: [OK]
Bringing up loopback interface: [OK]
#

I also tried another short program that spawns a child process, I can then issue signal 19 to stop the child process and restart with signal 18.

I still do not see [OK] message and prompt.

Thanks.
 
Old 07-09-2010, 08:50 AM   #6
salous
LQ Newbie
 
Registered: Jul 2010
Posts: 2

Rep: Reputation: 0
Quote:
Originally Posted by ploceus View Post
Yes, but servers also run in infinite loop, waiting for something, like incoming messages, waiting for other processes? How are those applications able to run forever and still able to get prompt back?
how about letting you program run in the background by using the ampersand symbol?

for example:
/usr/local/bin/foo &

hope that helps.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Prompt does not return sasurfman Slackware 4 01-16-2010 11:20 PM
return value from child to parent process prabhat ranjan Programming 3 02-12-2008 06:40 PM
nohup command in script doesn't return to system console prompt beammeup Linux - Software 4 02-05-2007 02:01 PM
My computer sometimes won't return me to the prompt. wilsonsamm Linux - General 1 08-22-2006 05:32 AM
LILO CRC error when I hit carriage return at prompt loopyzort Linux - Newbie 0 07-15-2004 01:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:26 PM.

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