2 Replies
      Latest reply on Aug 14, 2019 2:09 PM by ColonelPanic
      ColonelPanic Level 1 Level 1 (0 points)

        I have been developing a suit of inhouse applications (MacOS X, not iOS) for a client and I'm working I a "master application" to install/update the different applications in the toolset. Now I'm trying to figure out the best way to do what I did way back in the Objective-C times for another client, letting the programs, in case of something accidently goes terrible wrong, report to the "master application" something like "Mayday! Crash and burn here", so the master application can intercept that in some way ticket file in a Application Support folder or something similar, but after reading Quinn's (Hi Quinn, havent seen you since WWDC 2008 or G5 Optimization workshop in Stockholm 2003) nice piece on howto not make your own crashreporter (not really what I'm after anyway), I still stand clueless on the best approach to trap a crash. In the objective-C days I did this:


        // Signal handler

        void mySigHandler(int sig)


          NSLog(@"##### SigHandler(%d) called", sig);


          // reset sighandler

          signal(sig, mySigHandler);

        // Do whatever I needed before gracefully dying in peace



        and in main (whatever signals I wanted to handle

        // SIGTERM - registration

          signal( SIGTERM, mySigHandler);


        / Totte

        • Re: Trap a crash and inform a master application
          eskimo Apple Staff Apple Staff (12,665 points)

          The best option, IMO, is to avoid trying to catch the crash on the way down, but instead notice on the way back up.  Something like this:

          1. When your app starts, create a file that indicates that it’s running.

          2. When it terminates cleanly, delete that file.

          3. If it launches and discovers the file is still present, it must have crashed.

          4. Your app can then offer to report this, at which point it can notify your management app of the situation.

          The nice thing about this approach is that you don’t have to write any code that runs at crash time, which is where things start getting hard.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

            • Re: Trap a crash and inform a master application
              ColonelPanic Level 1 Level 1 (0 points)

              Hi Quinn,
              ticket files has been in my bucket of ideas, and as the apps are launched through the command master, ( can't guarantee though that the users wont add the to the dock ) it knows something is launched and I already have code to check if something is running (to handle "need to quit to update scenarios"), so this approach it is then.
              I can always add a check for running to the look and check state machine to see who is running and who is no longer running and the file is still there, and then I can grab the crashlog and zip it up and hurl it back to the DB repository for later dissection. I think I have a plan worked out.


              / Totte