LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-29-2016, 02:15 PM   #1
moosejaw
LQ Newbie
 
Registered: Jan 2016
Posts: 4

Rep: Reputation: Disabled
Syntax/invocation of rc.local vs. rc.local_shutdown


I'm curious why, in the Slackware rc.d scripts, the local startup and shutdown scripts (/etc/rc.d/rc.local and /etc/rc.d/rc.local_shutdown, respectively) are invoked differently:
  • rc.local is invoked without an argument: when it is called in /etc/rc.d/rc.M, the syntax is
    Code:
    . /etc/rc.d/rc.local
  • rc.local_shutdown is invoked with a "stop" argument: in /etc/rc.d/rc.{6,K}, the syntax is
    Code:
    /etc/rc.d/rc.local_shutdown stop

This entails some differences in how one writes rc.local and rc.local_shutdown (though rc.local_shutdown will happily ignore the "stop" parameter if you don't tell it to do anything with it, as far as I can tell).

This isn't a problem, obviously, but I'm just curious why things are set up in this way. Why the disparity in how these two scripts are handled by the system?
 
Old 01-29-2016, 02:27 PM   #2
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,661

Rep: Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784
From BASH Howto:
Quote:
When a file is sourced (by typing either source filename or . filename at the command line), the lines of code in the file are executed as if they were printed at the command line. This is particularly useful with complex prompts, to allow them to be stored in files and called up by sourcing the file they are in.
 
2 members found this post helpful.
Old 01-29-2016, 02:52 PM   #3
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
There's a lot of inconsistency in rc.S and rc.M relating to launching the other rc.* files.
Some are sourced, some called with "sh rc.something", and some are executed directly. Personally, I'd prefer them all to be invoked directly as /etc/rc.d/rc.something (if only for the sake of consistency) and left to rely on the "#!" line to decide what shell they run in. I actually went through it all on 14.1 at one point and converted them to run that way. Didn't see any adverse effects, but that was a while ago and I don't have the changes any more.

In the old days, one would source rather than exec to avoid the fork/exec and process setup/teardown overhead associated with spawning a new shell process, but with today's hardware the speed saving is unlikely to be noticeable and its my belief that the additional reliability of running independent shells isolated from each other rather than sourcing them would outweigh it.

The inconsistency is a bit ugly, but as you say, it's not really hurting anything (other than being something systemd proponents can point at and go "EWWWWWWWWWWWW!" ). I'd be happy to see it changed, but if its not, I wouldn't make a fuss.

Last edited by GazL; 01-29-2016 at 03:13 PM.
 
1 members found this post helpful.
Old 01-30-2016, 08:42 PM   #4
moosejaw
LQ Newbie
 
Registered: Jan 2016
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks both. I get that sourcing is useful for complex prompts, as the bash howto says. It seems to me it would be equally useful for /etc/rc.d/rc.local_shutdown, which is just as likely as /etc/rc.d/rc.local to consist of complex prompts. Anyway, again, not a big deal, but thanks for indulging my curiosity here.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] rc.local_shutdown not working! Ne36u12Y Slackware 17 02-04-2015 04:08 PM
rc.local and rc.local_shutdown handling Richard Cranium Slackware 9 11-10-2014 02:37 PM
rc.6 and rc.local_shutdown markush Slackware 6 03-29-2013 06:12 PM
rsync syntax for local copy hoover93 Linux - Software 3 12-21-2012 02:39 AM
'Housekeeping' with /etc/rc.d/rc.local_shutdown? andrew.46 Slackware 3 08-05-2008 07:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:18 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