• 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: Xcode interferes with signal handler
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Xcode interferes with signal handler


  • Subject: Re: Xcode interferes with signal handler
  • From: Pascal Bourguignon via Cocoa-dev <email@hidden>
  • Date: Tue, 30 Jan 2024 23:45:44 +0100

Le 30/01/2024 à 20:31, Gabriel Zachmann via Cocoa-dev a écrit :
I am setting up a signal handler in my app like this:

    void *e = signal( SIGUSR1, signal_handler );
    if ( e == SIG_ERR )
       ...

It works (i can 'kill -30 <pid>'), BUT ONLY, if I run my app outside of Xcode.

When I launch it from Xcode, and I send a SIGUSR1 to my app, it always breaks
at mach_msg2_trap.
Obviously, this is a bit tedious for developing, since now I always have to go
through Product / Archive / Distribute ...

Any ideas, how I can prevent this from happening?

And it's unclear to me what's going on. Can Xcode really prevent signal(3) from
installing a signal handler?
Or does a kill on the command line deliver the signal to several processes, one
of them, maybe, an ancillary process from Xcode?


There must be a command to forward the signals.

With gdb, you did:

    handle SIGUSR1 nostop pass

If Xcode still uses lldb, then it should be something like:

    process handle SIGUSR1 --stop false --pass true

or with the GUI, assuming some version:

In Xcode, you can configure the signal handling behavior using the "Scheme" settings. Here's how you can do it:

1. Open your project in Xcode.
2. Select the target you want to configure the signal handling for.
3. Go to "Product" in the menu bar, then select "Scheme" and click on "Edit Scheme..."
4. In the left sidebar of the "Run" section, select "Diagnostics".
5. Under the "Signal Handling" section, you can add or remove signals based on your requirements. 6. To add a signal, click the "+" button and enter the name of the signal (e.g., "SIGTERM"). 7. By default, the signal will be set to stop the program. To make the program handle the signal, uncheck the "Stop" checkbox next to the signal.
8. Click "Close" to save the changes.


From memory, I've not used it recently.
--
__Pascal Bourguignon__

_______________________________________________

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

References: 
 >Sending SIGUSR1 to a process (From: Gabriel Zachmann via Cocoa-dev <email@hidden>)
 >Re: Sending SIGUSR1 to a process (From: Saagar Jha via Cocoa-dev <email@hidden>)
 >Xcode interferes with signal handler (was: Sending SIGUSR1 to a process) (From: Gabriel Zachmann via Cocoa-dev <email@hidden>)

  • Prev by Date: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
  • Next by Date: Re: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
  • Previous by thread: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
  • Next by thread: Re: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
  • Index(es):
    • Date
    • Thread