开发者

How can i be notified that the user is logging out?

开发者 https://www.devze.com 2022-12-14 03:34 出处:网络
I am writing a user agent that needs to perform some cleanup when the user logs o开发者_JAVA技巧ut of OS X.The agent is NOT receiving a SIGINT (neither SIGTERM, and neither SIGKILL) signal.Because of

I am writing a user agent that needs to perform some cleanup when the user logs o开发者_JAVA技巧ut of OS X. The agent is NOT receiving a SIGINT (neither SIGTERM, and neither SIGKILL) signal. Because of this, the agent process is remaining as a "ghost" process running on the Mac, and it will no longer respond to any attempts I do to kill it. I need to be notified that the user is logging out and then I can handle the shut-down of the Agent gracefully.

I know about the CFNotificationCenter, but I could not find any example on how to use it for logout. Actually I did not find a list describing the possible notifications (at least the standard ones) that I can observe using the CFNotificationCenter. Can anyone help me please ?

Regards

Alan


Apple has a document describing how this is done. Essentially, you use the SCDynamicStoreCopyConsoleUser to check the currently signed in user. If this is loginwindow, you know that no user is logged in. You can then register for a notification whenever the current GUI console user changes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号