As @keefaz says, the "dot command" runs in the current shell (which is handy for setting environment variables on the fly that will "stick" until the current shell exits). Every other executable forks and executes in a new shell (including every time you type a command and hit the enter key).
My
/etc/rc.d/rc.local starts up a bunch of stuff:
Code:
[
cat rc.local
#!/bin/sh
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
# Start apcupsd
if [ -x /etc/rc.d/rc.apcupsd ]; then
/etc/rc.d/rc.apcupsd start
fi
# Start postgresql
if [ -x /etc/rc.d/rc.postgresql ]; then
/etc/rc.d/rc.postgresql start
fi
# Start tomcat
if [ -x /etc/rc.d/rc.tomcat ]; then
/etc/rc.d/rc.tomcat start
fi
# Start vboxdrv
# If you do not wish this to be executed here then comment it out,
# and the installer will skip it next time.
if [ -x /etc/rc.d/rc.vboxdrv ]; then
/etc/rc.d/rc.vboxdrv start
fi
# Start vboxballoonctrl-service
# If you do not wish this to be executed here then comment it out,
# and the installer will skip it next time.
if [ -x /etc/rc.d/rc.vboxballoonctrl-service ]; then
/etc/rc.d/rc.vboxballoonctrl-service start
fi
# Start vboxautostart-service
# If you do not wish this to be executed here then comment it out,
# and the installer will skip it next time.
if [ -x /etc/rc.d/rc.vboxautostart-service ]; then
/etc/rc.d/rc.vboxautostart-service start
fi
# Start vboxweb-service
# If you do not wish this to be executed here then comment it out,
# and the installer will skip it next time.
if [ -x /etc/rc.d/rc.vboxweb-service ]; then
/etc/rc.d/rc.vboxweb-service start
fi
Note: no
exits. The commands that are executed start daemons, which fork and exec a child process, the parent dies, but the daemon process continues to run until the system is shut down. By including an
exit, you're killing the parent process (which is the process that runs everything in
/etc/rc.d/rc.local). You don't want that to happen, so don't include
exits (and don't include "dot commands" either unless you really know the consequences of doing so).
If you execute
Code:
ps -efl | pg
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 1088 poll_s Aug09 ? 00:00:05 init [3]
1 S root 2 0 0 80 0 - 0 kthrea Aug09 ? 00:00:00 [kthreadd]
1 S root 3 2 0 80 0 - 0 smpboo Aug09 ? 00:00:01 [ksoftirqd/0]
1 S root 5 2 0 60 -20 - 0 worker Aug09 ? 00:00:00 [kworker/0:0H]
1 S root 7 2 0 -40 - - 0 smpboo Aug09 ? 00:00:00 [migration/0]
1 S root 8 2 0 80 0 - 0 rcu_gp Aug09 ? 00:00:00 [rcu_bh]
1 S root 9 2 0 80 0 - 0 rcu_gp Aug09 ? 00:01:42 [rcu_sched]
1 S root 10 2 0 -40 - - 0 smpboo Aug09 ? 00:00:00 [migration/1]
1 S root 11 2 0 80 0 - 0 smpboo Aug09 ? 00:00:00 [ksoftirqd/1]
1 S root 13 2 0 60 -20 - 0 worker Aug09 ? 00:00:00 [kworker/1:0H]
The PID is the daemon process identification number, the PPID is the parent process identification number (this list is really abbreviated, it's multiple pages long). PID 1 is
init, PPID 0 is the kernel (you don't want to exit either of those) and all the rest are the daemons that provide services.
Hope this helps some.