Results 1 to 4 of 4
Hi.
I have an a script in /etc/rc.d/init.d script that I would like to start and stop my sample application. I have named my script "foo", then I can start ...
- 07-09-2010 #1Just Joined!
- Join Date
- Jul 2007
- Posts
- 7
init.d script does not return prompt
Hi.
I have an a script in /etc/rc.d/init.d script that I would like to start and stop my sample application. I have named my script "foo", then I can start running my application my typing
$ foo start
but this does not return [OK] like other scripts do and does not return to shell prompt.
My application is basically like this
int main()
{
do {
printf("Hi\n");
sleep(1);
} while (1);
}
What is missing from my application that prevents from returning the shell prompt?
Thanks for help.
- 07-09-2010 #2
you're kidding, don't you? do you know what a loop is / what it does?
Last edited by Kloschüssel; 07-09-2010 at 08:05 AM.
- 07-09-2010 #3Just Joined!
- Join Date
- Jul 2007
- Posts
- 7
Many servers and apps that start from init.d have infinite loops in it. Usually they wait for some other process to finish, or is waiting for some message.
I also tried another test program (a.out for example) where it spawns a child process. Then I can temporarily halt or continue the child process using signals. This sample program does not use infinite loop and still there is no
[OK] message after
/etc/rc.d/init.d/foo start
and does not return to prompt either.
Any ideas of what I can do to get [ OK ] message and prompt?
- 07-10-2010 #4
they have infinite loops to wait on something. your loop won't stop, thus never return, thus it will never give you your terminal back. the init scripts start up things and the calling init process has to wait for each init script to finish, otherwise he will never know if something went wrong and start your networking without a filesystem or even worse. the init process is (and must be by definition) strictly deterministic.
on debian based unix the lsb init scripts provide the api for the status output and return codes.
LSBInitScripts - Debian Wiki


Reply With Quote