Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


Search this Thread
Old 05-27-2011, 03:35 PM   #1
Keith Hedger
Senior Member
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 1,167

Rep: Reputation: 254Reputation: 254Reputation: 254
Boot script query ( /etc/rc.d/rc.S/M/0)

Got a query on some odd scripting in the boot up/ shutdown scripts, these scripts in turn call other scripts in /etc/rc.d but do so in an odd way and I want to know why this is, if you look in /etc/rc.d/rc.M the way the scripts are called is different
hal is called by
sh /etc/rc.d/rc.hald start
acpid is called by
. /etc/rc.d/rc.acpid start
cups is called by
/etc/rc.d/rc.cups start
The . in the acpid call tells the interpreter to include the file rather than run as a separate script, and there are other examples, from line 56 of /etc/rc.d/rc.0
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
  /etc/rc.d/rc.local_shutdown stop

# Stop the Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
  /etc/rc.d/rc.httpd stop

# Stop the MySQL database:
if [ -r /var/run/mysql/ ]; then
  . /etc/rc.d/rc.mysqld stop

# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
  . /etc/rc.d/rc.samba stop

# Shut down the NFS server:
if [ -x /etc/rc.d/rc.nfsd ]; then
  /etc/rc.d/rc.nfsd stop
Is there any reason for these different ways of calling the scripts?
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-27-2011, 05:32 PM   #2
Alien Bob
Slackware Contributor
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,492

Rep: Reputation: Disabled
Including other rc scripts through the use of the "source" command (which is the dot command's actual name) saves creating a sub-shell. Forking a subshell adds a little bit of overhead to your boot time.

However, if the script which gets sourced contains an "exit" statement it becomes a different story. Look at the rc.hald script which checks for the existence of dbus and aborts with "exit 1" if dbus is not found.
Now, if rc.hald would have been sourced it would be effectively part of rc.M. The "exit 1" statement would then abort rc.M as well, the result would be a broken system because most of rc.M would not be executed. Therefore, rc.hald is started in a subshell so that in case of that error exit, rc.M can just continue with the other bits and pieces.

2 members found this post helpful.
Old 05-28-2011, 06:05 AM   #3
Keith Hedger
Senior Member
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 1,167

Original Poster
Rep: Reputation: 254Reputation: 254Reputation: 254
Thanks! didn't think to check for an exit statement in the scripts, but it still seems odd to mix the two different ways of running the rc scripts just to save a small bit of boot time.


boot, script

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
oracle query script investmentbnker75 Programming 1 11-15-2008 10:41 PM
DNS query script Braynid Linux - Newbie 17 07-05-2006 06:45 AM
msyql query from shell script hamish Linux - Software 5 06-02-2006 10:06 AM
Simple shell script query sachinh Programming 5 09-07-2005 05:02 AM
Query about script variable phantomdude Linux - Newbie 1 03-18-2004 12:21 PM

All times are GMT -5. The time now is 04:05 AM.

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 @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration