Re: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
I think , I found the solution, so just for the record (so that others will find it using Google): Launch the app in the debugger on the command line : lldb /private/tmp/Build/Products/Debug/MyApp.app In lldb's command line: process handle -p true -s false -n true // otherwise lldb will stop on SIGUSR1 Set your breakpoints as needed, then r --no-stdin Then you can 'kill -30 ' without getting those annoying breaks in mach_msg2_trap. Hope this helps. Gabriel. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
That’s a great tip Jens. Gabriel, if you build your app with different dev/release schemes, you could detect your build scheme and then execute the desired process based on if you’re able to debug or not. Just expose the environment variable for $CONFIGURATION in an info.plist file, read it into a variable and then manage your response based on what the value is. If you want details on that, contact me off list and I’ll show you. Reference: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html Hopefully, Jens’s tip will get you what you need! Best, Alex Zavatone > On Jan 31, 2024, at 12:20 AM, Jens Miltner via Cocoa-dev > wrote: > > Xcode intercepts signals in the process being debugged (for good reason). > You can ignore specific signals in Xcode (i.e. pass them through to the > process being debugged) by breaking into the debugger, then enter in the > Xcode console part (example for SIGUSR1): > > process handle SIGUSR1 -s false > process handle SIGUSR1 -p true > > HTH, > -jens > > >> Von: Gabriel Zachmann >> Betreff: Xcode interferes with signal handler (was: Sending SIGUSR1 to a >> process) >> Datum: 30. Januar 2024 um 20:31:45 MEZ >> An: "cocoa-dev@lists.apple.com" >> >> >> 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 '), 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? >> >> >> Best regards, Gabriel >> > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com > > This email sent to z...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
Xcode intercepts signals in the process being debugged (for good reason). You can ignore specific signals in Xcode (i.e. pass them through to the process being debugged) by breaking into the debugger, then enter in the Xcode console part (example for SIGUSR1): process handle SIGUSR1 -s false process handle SIGUSR1 -p true HTH, -jens > Von: Gabriel Zachmann > Betreff: Xcode interferes with signal handler (was: Sending SIGUSR1 to a > process) > Datum: 30. Januar 2024 um 20:31:45 MEZ > An: "cocoa-dev@lists.apple.com" > > > 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 '), 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? > > > Best regards, Gabriel > ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Xcode interferes with signal handler (was: Sending SIGUSR1 to a process)
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 '), 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? Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending SIGUSR1 to a process
A long time ago, I was issuing terminal commands from Xcode. I’ve got a simple console app that executes a SIP export to PDF and another case where I was executing a sleep of the current process. You can even execute an Applescript to perform a terminal command. This may help. https://forums.developer.apple.com/forums/thread/90111 Cheers, Alex Zavatone > On Jan 29, 2024, at 1:06 AM, Gabriel Zachmann via Cocoa-dev > wrote: > > IIRC, one process cannot send a Unix signal to another one. > At least, not any more, and not without special privileges. > > But would it be possible for a user to send a SIGUSR1 (using 'kill -30 ' > on the command line) to a process they own? > > I couldn't find information about that. > In fact, in the developer docs i couldn't find any info about Unix signals, > what is possible or not under the new security regime in macOS. > (I can't remember where i read about the new limitations regarding signals > under the new security regime.) > > Any info will be highly appreciated. > > Best regards, Gabriel > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com > > This email sent to z...@mac.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending SIGUSR1 to a process
> > Yes, this should work. The only changes I know of is that you can’t signal > some Apple processes these days if System Integrity Protection is engaged. I have tried it like the following, but to no avail: void signal_handler( int sig ) { logMessage( LogClient, [NSString stringWithFormat: @"signal %d caught", sig], NO ); } // install signal handler In the init method of my app I have: void *e = signal( SIGUSR1, signal_handler ); if ( e == SIG_ERR ) { char * errmesg = strerror( errno ); [self logMessage: [NSString stringWithFormat: @"Installing signal handler failed: %s", errmesg] asError: YES]; } When I run my app (from Xcode), I don't get any error message, but sending a SIGUSR1 (using 'kill' on the command line) just makes it stop in mach_msg2_trap. Stack trace: start, main, NSApplicationMain, mach_msg2_trap. My signal_handler won't get called. smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Sending SIGUSR1 to a process
Yes, this should work. The only changes I know of is that you can’t signal some Apple processes these days if System Integrity Protection is engaged. Saagar Jha > On Jan 28, 2024, at 23:06, Gabriel Zachmann via Cocoa-dev > wrote: > > IIRC, one process cannot send a Unix signal to another one. > At least, not any more, and not without special privileges. > > But would it be possible for a user to send a SIGUSR1 (using 'kill -30 ' > on the command line) to a process they own? > > I couldn't find information about that. > In fact, in the developer docs i couldn't find any info about Unix signals, > what is possible or not under the new security regime in macOS. > (I can't remember where i read about the new limitations regarding signals > under the new security regime.) > > Any info will be highly appreciated. > > Best regards, Gabriel > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com > > This email sent to saa...@saagarjha.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Sending SIGUSR1 to a process
IIRC, one process cannot send a Unix signal to another one. At least, not any more, and not without special privileges. But would it be possible for a user to send a SIGUSR1 (using 'kill -30 ' on the command line) to a process they own? I couldn't find information about that. In fact, in the developer docs i couldn't find any info about Unix signals, what is possible or not under the new security regime in macOS. (I can't remember where i read about the new limitations regarding signals under the new security regime.) Any info will be highly appreciated. Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com