Re: Substitute for kill(2)?

2023-07-25 Thread Jack Brindle via Cocoa-dev
I would agree with the use of Distributed Notifications, but there is a new 
limitation that was added a few years ago. The receiver must be in the same 
login. You can no longer use it to send notifications from one user app to a 
different user’s app. This came to light for me when I was trying to send a 
notification from a root app to a user app. Fear not, though, there is a form 
of Notification that works perfectly for this - CFNotifications. The two, of 
course, are closely related, but CFNotifications allow you to use the Darwin 
Notification Center which allows cross-user notifications.

These are easy to use, and, I believe, still the best way to send info from one 
app to another in the Mac system. 

Jack


> On Jul 25, 2023, at 9:38 AM, Rob Petrovec via Cocoa-dev 
>  wrote:
> 
> NSDistributedNotificationCenter is a way to send a notification out across 
> the system. Only processes that are listening for the notification will 
> receive it and have a chance to do something with it. It’s like yelling out 
> in a crowded room to tell a single person something. Everyone will hear your 
> message, but only one will be listening. Make sense?  
> https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?changes=_4=objc
> 
> But what it really sounds like you want to use XPC (Cross Process 
> Communication) for a more targeted messaging (possibly with payloads) between 
> your app and menuling.  
> https://developer.apple.com/documentation/xpc?language=objc
> 
> —Rob
> 
> 
>> On Jul 25, 2023, at 7:51 AM, Gabriel Zachmann  wrote:
>> 
>> Thanks a lot for your responses!
>> 
>> Sorry for the misunderstanding: I don't want to kill the other process.
>> (In case you forgot: the kill(2) system call is for sending unix signals to 
>> processes, which can listen to those signals (at least, most of them). I 
>> just want to signal the other process, not really kill it. So, SIGUSR1 
>> would've been my choice, if macOS would allow me to send a signal.)
>> 
>> What do you mean by "distributed notification" ?
>> How would I send it?
>> 
>> 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/jackbrindle%40me.com
> 
> This email sent to jackbrin...@me.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: Substitute for kill(2)? (James Walker)

2023-07-25 Thread Gabriel Zachmann via Cocoa-dev
>>
> An XPC service isn't an app, and wouldn't you need an app to run an
> NSStatusItem, which I assume is what's meant by a "menu bar item"?

Oh, sorry, PS:
yes, I do create

let statusBar = NSStatusBar.system
statusBarItem_ = statusBar.statusItem( withLength: 
NSStatusItem.variableLength )

in my app ...




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: Substitute for kill(2)? (James Walker)

2023-07-25 Thread Gabriel Zachmann via Cocoa-dev

>>
> An XPC service isn't an app, and wouldn't you need an app to run an
> NSStatusItem, which I assume is what's meant by a "menu bar item"?
>

I am just a beginner in "menu bar items" , but what I have is an

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate

which Xcode compiles into an app, which, when launched, just sits in the menu 
bar.


> See  for a discussion
> of XPC versus some other methods of communication.
>

Thanks for the link!

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: Substitute for kill(2)?

2023-07-25 Thread Gabriel Zachmann via Cocoa-dev
> NSDistributedNotificationCenter is a way to send a notification out across 
> the system. Only processes that are listening for the notification will 
> receive it and have a chance to do something with it. It’s like yelling out 
> in a crowded room to tell a single person something. Everyone will hear your 
> message, but only one will be listening. Make sense?

Definitely. Sounds great for my purpose.
It will happen only very rarely.
And I don't have any payload.

>  
> https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?changes=_4=objc
>

Thanks a lot for the pointer!

> But what it really sounds like you want to use XPC (Cross Process 
> Communication) for a more targeted

I had looked into that but it appeared to heavy-weight for my purposes.


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: Substitute for kill(2)?

2023-07-25 Thread James Walker via Cocoa-dev

On 7/25/23 7:38 AM, Rob Petrovec via Cocoa-dev wrote:

NSDistributedNotificationCenter is a way to send a notification out across the 
system. Only processes that are listening for the notification will receive it and 
have a chance to do something with it. It’s like yelling out in a crowded room to 
tell a single person something. Everyone will hear your message, but only one will 
be listening. Make sense?  
https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?changes=_4=objc

But what it really sounds like you want to use XPC (Cross Process 
Communication) for a more targeted messaging (possibly with payloads) between 
your app and menuling.  
https://developer.apple.com/documentation/xpc?language=objc

An XPC service isn't an app, and wouldn't you need an app to run an 
NSStatusItem, which I assume is what's meant by a "menu bar item"?


See  for a discussion 
of XPC versus some other methods of communication.


___

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: Substitute for kill(2)?

2023-07-25 Thread Rob Petrovec via Cocoa-dev
NSDistributedNotificationCenter is a way to send a notification out across the 
system. Only processes that are listening for the notification will receive it 
and have a chance to do something with it. It’s like yelling out in a crowded 
room to tell a single person something. Everyone will hear your message, but 
only one will be listening. Make sense?  
https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?changes=_4=objc

But what it really sounds like you want to use XPC (Cross Process 
Communication) for a more targeted messaging (possibly with payloads) between 
your app and menuling.  
https://developer.apple.com/documentation/xpc?language=objc

—Rob


> On Jul 25, 2023, at 7:51 AM, Gabriel Zachmann  wrote:
> 
> Thanks a lot for your responses!
> 
> Sorry for the misunderstanding: I don't want to kill the other process.
> (In case you forgot: the kill(2) system call is for sending unix signals to 
> processes, which can listen to those signals (at least, most of them). I just 
> want to signal the other process, not really kill it. So, SIGUSR1 would've 
> been my choice, if macOS would allow me to send a signal.)
> 
> What do you mean by "distributed notification" ?
> How would I send it?
> 
> 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


Re: Substitute for kill(2)?

2023-07-25 Thread Gabriel Zachmann via Cocoa-dev
Thanks a lot for your responses!

Sorry for the misunderstanding: I don't want to kill the other process.
(In case you forgot: the kill(2) system call is for sending unix signals to 
processes, which can listen to those signals (at least, most of them). I just 
want to signal the other process, not really kill it. So, SIGUSR1 would've been 
my choice, if macOS would allow me to send a signal.)

What do you mean by "distributed notification" ?
How would I send it?

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: Substitute for kill(2)?

2023-07-25 Thread Rob Petrovec via Cocoa-dev
Yeah, you might be able to send out a distributed notification and have the 
menuling listen for it. When it receives it it can kill itself or go through 
the normal teardown/quit procedure.

—Rob


> On Jul 25, 2023, at 6:15 AM, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> What if you called a method in the other process and the other process kills 
> itself with a kill?  
> 
> Is kill no longer functional from any process?
> 
>> On Jul 25, 2023, at 2:49 AM, Gabriel Zachmann via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> Is there a simple way for one process to send a single signal to another 
>> process?
>> Both processes are my programs, one is a regular app, the other a menu bar 
>> item.
>> Both are launched by the same user.
>> 
>> In the old unix days, I would have used kill(2) and send a SIGUSR1 , but as 
>> far as I understand, this is no longer possible.
>> (At least,  not without privilege elevation, which seems too complicated.)
>> 
>> All hints and ideas will be 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/petrock%40mac.com
> 
> This email sent to petr...@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: Substitute for kill(2)?

2023-07-25 Thread Alex Zavatone via Cocoa-dev
What if you called a method in the other process and the other process kills 
itself with a kill?  

Is kill no longer functional from any process?

> On Jul 25, 2023, at 2:49 AM, Gabriel Zachmann via Cocoa-dev 
>  wrote:
> 
> Is there a simple way for one process to send a single signal to another 
> process?
> Both processes are my programs, one is a regular app, the other a menu bar 
> item.
> Both are launched by the same user.
> 
> In the old unix days, I would have used kill(2) and send a SIGUSR1 , but as 
> far as I understand, this is no longer possible.
> (At least,  not without privilege elevation, which seems too complicated.)
> 
> All hints and ideas will be 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


Substitute for kill(2)?

2023-07-25 Thread Gabriel Zachmann via Cocoa-dev
Is there a simple way for one process to send a single signal to another 
process?
Both processes are my programs, one is a regular app, the other a menu bar item.
Both are launched by the same user.

In the old unix days, I would have used kill(2) and send a SIGUSR1 , but as far 
as I understand, this is no longer possible.
(At least,  not without privilege elevation, which seems too complicated.)

All hints and ideas will be 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