Hi Dave, Thanks for your reply. I was hoping to avoid handling that inspection myself, but even if I go that route there's another problem: the ancillary tool isn't a proper bundle, it's just a plain executable, so NSBundle's initializers will just return nil. That's a pity because there's even -[NSBundle preflightAndReturnError:] which sounds to be exactly what I want.
Offhand does anyone know how to inspect the architecture(s) of a plain executable file? I've been googling for a little bit and haven't hit upon anything that works yet. Thanks, ~Martin On Sep 1, 2011, at 2:12 PM, Dave DeLong wrote: > You could probably catch this before attempting to launch the task. Create a > new NSBundle object pointing at the executable path, and then ask the bundle > for the -executableArchitectures, and see if one of the returned values > matches the architecture of the machine you're running. If it matches, then > launch the task. :) > > Cheers, > > Dave > > On Sep 1, 2011, at 2:09 PM, Martin Wierschin wrote: > >> Hello all, >> >> My application sometimes need to run an ancillary program (included in the >> app's resources). I do this via NSTask and normally it works great. >> >> The problem is that this ancillary program is sometimes Intel-only, or >> sometimes PPC-only, while the main application is Universal. The use of this >> ancillary program is not mandatory, so displaying an error message, or using >> a fallback solution is acceptable. The issue is that trying to run an >> ancillary program on an unsupported architecture triggers a hard crash: >> >>>> Exception Type: EXC_BREAKPOINT (SIGTRAP) >>>> Exception Codes: 0x0000000000000001, 0x000000009030c0b0 >>>> Crashed Thread: 0 >>>> >>>> Application Specific Information: >>>> *** NSTask: Task create for path '.../Resources/mysubtool' failed: 86, >>>> "Bad CPU type in executable". Terminating temporary process. >>>> *** multi-threaded process forked *** >> >>>> >>>> Thread 0 Crashed: >>>> 0 com.apple.Foundation 0x9030c0b0 >>>> ___NEW_PROCESS_COULD_NOT_BE_EXECD___ + 0 >>>> 1 com.apple.Foundation 0x901d0354 -[NSConcreteTask >>>> launchWithDictionary:] + 2472 >> >> Is there an elegant way to catch this? I'd rather not try to figure out the >> arch of the ancillary program, host arch, and (if relevant) whether Rosetta >> is installed or not. >> >> Thanks, >> ~Martin >> >> _______________________________________________ >> >> 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: >> http://lists.apple.com/mailman/options/cocoa-dev/davedelong%40me.com >> >> This email sent to davedel...@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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com