Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 976691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:47:16+00:00 2026-05-16T03:47:16+00:00

In my Cocoa application I need to run a task that uses unstable unfixable

  • 0

In my Cocoa application I need to run a task that uses unstable unfixable code. It takes little input, works independently from the rest of the app, and generates thousands of ObjC objects as a result.

How can I run the unstable part and let it crash without taking down whole application?

Is it possible to fork() Cocoa application? How UI, threads, GC, KVO, runloops are going to behave when forked?

Can I avoid creating standalone executable launched via NSTask?

If I launch separate process, how can I send and receive ObjC object instances? (I’d rather not serialize/unserialize them myself, and I need to keep them after child process ends).

How does OS X handle this problem for Spotlight and Quicklook plugins?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:47:17+00:00Added an answer on May 16, 2026 at 3:47 am

    Is it possible to fork() Cocoa application?

    Yes, but you pretty much have to exec immediately. Core Foundation will throw an exception if you try to use certain Cocoa methods or CF functions between fork and exec (or without execking at all). You might get away with some things (I was able to ask a window its frame, for example), but nothing is safe.

    Launching an NSTask, of course, counts as fork and exec together, averting the problems of skipping or postponing the exec.

    How UI, threads, GC, KVO, runloops are going to behave when forked?

    UI: Windows (the actual ones on the screen) are not duplicated. Of course, you can’t talk to your NSWindow and NSView objects anyway.

    Threads: Not carried over to the subprocess. This is not as good as it may sound, as problem cases abound; for one, another thread might have held a lock in the parent, which remains locked in the child even though the thread that held it is absent.

    GC: Well, the garbage collector runs on a thread…

    KVO: Should be fine, since observation is normally triggered either explicitly or by KVO-supplied wrapper accessors.

    Run loops: One per thread, so the main thread’s run loop should still exist, but it will die if you return to it.

    Can I avoid creating standalone executable launched via NSTask?

    Nope.

    If I launch separate process, how can I send and receive ObjC object instances?

    If you don’t exec, you don’t.

    Otherwise, you can use DO.

    (I’d rather not serialize/unserialize them myself, and I need to keep them after child process ends).

    Then you’ll need to make a copy in the parent process. I don’t know whether you can use copyWithZone: here; probably not. I suspect you will have to do some sort of plist- or archive-based serialization/unserialization.

    How does OS X handle this problem for Spotlight and Quicklook plugins?

    Spotlight has mdworker; Quick Look has something similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.