• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?


  • Subject: Re: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 25 Mar 2009 03:41:39 -0500

On Mar 25, 2009, at 2:50 AM, Påhl Melin wrote:

I have a C++ singleton class where you call methods to execute
commands that are actually performed by a background thread. When a
command is "requested" it is put in a queue and I use raise(SIGUSR2)
to wake-up the background thread. The reason I use signals to wake-up
the background thread is that it communicates with other processed
using Unix Domain Sockets and is listening to socket activity using a
kqueue() and can also conveniently be used to listen to raised
signals.

Have you considered using a pipe instead? Just send a single byte (contents unimportant) on the pipe to wake the thread. The thread should drain the pipe whenever it wakes up, and then check whatever state information necessary to do its work. Etc.



When the singleton is constructed the first time I use signal(SIGUSR2,
SIG_IGN) to ignore the default signal handler to kill the process. And
this works great when running the program both in Xcode and in a
terminal window BUT when I put a breakpoint in the program and GDB is
run, the program crashes when raise(SIGUSR2) is executed and kills the
process as if the signal(SIGUSR2, SIG_IGN) had not been called (which
I know has been called).

Are you sure the process is dying? By design, GDB stops (but doesn't kill) the process whenever it receives a signal. It allows you to investigate the state of the process if the signal was unexpected.


You can control this behavior using GDB's "handle" command. Try typing "help handle" or "info handle" at GDB's prompt.

You can deliver the signal to the process using GDB's "signal" command. You can also continue the process without delivering the signal using "continue".

Regards,
Ken

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?
      • From: Påhl Melin <email@hidden>
References: 
 >signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB? (From: Påhl Melin <email@hidden>)

  • Prev by Date: Re: NSTableView updating checkboxes
  • Next by Date: Re: How to extract the basic info from an audio file?
  • Previous by thread: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?
  • Next by thread: Re: signal(SIGUSR2, SIG_IGN) not respected by Xcode/GDB?
  • Index(es):
    • Date
    • Thread