Borys Verebskyi
Borys Verebskyi

Reputation: 4278

Unexpected -psn_0_65552 command line argument after mac reboot

When I reboot my mac, if an application that I'm developing was running during reboot, macos starts that application right after restart with "-psn_0_65552" argument. I assume that this is related to "Reopen windows when logging back in" checkbox enabled on restart prompt. I tried to find any documentation about this argument, but failed. So, my questions:

  1. Is this behavior documented somewhere?
  2. Any other weird command-line arguments my application should be able to handle?
  3. Can I avoid my application reopening after mac restart?

Upvotes: 1

Views: 207

Answers (1)

CRD
CRD

Reputation: 53010

Nobody else has offered you anything yet so maybe this will help:

  1. Is this behavior documented somewhere?

The state preservation and restoration mechanism is at least partially documented through the methods you can call to participate in it, e.g. NSWindow's restorable & encodeRestorableStateWithCoder:, NSWindowDelegate's window:willEncodeRestorableState:, NSApplication's restoreWindowWithIdentifier:state:completionHandler: etc. However how the various AppKit classes preserve and restore all the information is not publicly documented (there is a statement to that effect in the docs somewhere).

  1. Any other weird command-line arguments my application should be able to handle?

Anybody's guess.

  1. Can I avoid my application reopening after mac restart?

Maybe. Some apps don't restart on relaunch, whether their authors control this or its happenstance I've no idea.

Here's a suggestion: write yourself a very basic GUI app which just saves the arguments and environment (you can use NSProcessInfo to get them all) at launch time to user defaults. Lunch your app from Xcode, Finder and Terminal. Reboot while its open. Look at the user defaults (look in its sandbox and open the .plist in Xcode). Notice anything? Want to rely on it? Your call.

Can you think of others way to track your app launches and user-initiated quits? Maybe setting and removing a flag in user defaults? Have fun!

HTH

Upvotes: 2

Related Questions