Forum: Ruby trap("CLD") - ignore TSTP signal

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
29c4aa352c992dc92a0cf025db59bca5?d=identicon&s=25 Christopher Horn (Guest)
on 2006-04-24 12:33
(Received via mailing list)
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
A5ae84b6af0a67cdea1db87706a11a6f?d=identicon&s=25 Yoann Guillot (Guest)
on 2006-04-24 12:55
(Received via mailing list)
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
29c4aa352c992dc92a0cf025db59bca5?d=identicon&s=25 Christopher Horn (Guest)
on 2006-04-24 13:04
(Received via mailing list)
On 24.04.2006, at 12:51, Yoann Guillot wrote:
> trap("CLD") {
> 	Process.wait
> 	if not $?.stopped?
> 		# notify daemon
> 	end

Works perfectly, thanks!

christopher
This topic is locked and can not be replied to.