trap("CLD") - ignore TSTP signal

Hi,

i’m writing a distrubuted process queueing and scheduling daemon
in Ruby (for Linux / MacOS X).

The scheduler can suspend Unix processes (TSTP signal), and resume
them with a CONT signal. This already works fine.

But the wrapper for the process is unable to differentiate between
a Suspend (TSTP) and a ‘normal’ termination of the child.

Here’s the code:

start

@pid = fork {
exec(@command)
}
trap(“CLD”) {
puts “P: Child pid #{@pid}: caught signal or terminated”
# notify daemon only if signal was not a TSTP
# … ?
}

which always outputs the line when the child process changes its state
(no matter if Suspend or Die) - which is the definition of CLD.

Is there any way for trap() to ignore the Suspend signal?
Adding ‘trap(“TSTP”, “IGNORE”)’ before ‘exec()’ will cause the process
to completely ignore the TSTP signals…

Maybe someone can help me.

Greetings from Austria,
christopher

Christopher Horn wrote:

But the wrapper for the process is unable to differentiate between
a Suspend (TSTP) and a ‘normal’ termination of the child.

trap(“CLD”) {
puts “P: Child pid #{@pid}: caught signal or terminated”

 # notify daemon only if signal was not a TSTP
Process.wait
if not $?.stopped?
	# notify daemon
end

On 24.04.2006, at 12:51, Yoann G. wrote:

trap(“CLD”) {
Process.wait
if not $?.stopped?
# notify daemon
end

Works perfectly, thanks!

christopher