signal handling with trap

jesse lazar jlazar at basicisp.net
Sun Feb 17 07:35:26 EST 2008


hello,

i am trying to learn a little about shell programming for no real 
reason. so i have taken to trying to make sense of the shell 
initialization process. i've got sys v init, or something, i don't 
really know. its a debian system. 

from what i gather: 
 + the init program is called on after the boot process
 + init reads /etc/inittab
 + init executes the shell script /etc/init.d/rcS

i'm stuck here because i cannot figure out the usage of the trap 
command. what i find bewildering is that i don't get a manpage for trap 
when i type in 'man trap' using the root account. where do i go for 
reference on the use of the trap command?

according to the book, shell programming, published by sams the usage 
would be:
	trap name signals
where name is a list of commands or the name of a shell function

thus the line 
	trap - INT QUIT TSTP
is going to execute '-' when any of the signals INT QUIT TSTP are 
issued? that doesn't seem right to me... '-' doesn't seem to be a 
command or a list of commands.


thanks,

jesse

########################################################
the following was pulled from the rcS script...
############################################################

for i in /etc/rcS.d/S??*
do
	# Ignore dangling symlinks for now.
	[ ! -f "$i" ] && continue

	case "$i" in
		*.sh)
			# Source shell script for speed.
			(
				trap - INT QUIT TSTP
				set start
				. $i
			)
			;;
		*)
			# No sh extension, so fork subprocess.
			$i start
			;;
	esac
done




More information about the gnhlug-discuss mailing list