Tried fiddling with AppleEvents & came up with this:
//Get the PID for a running application.
NSRunningApplication* runningApp = [[NSRunningApplication
runningApplicationsWithBundleIdentifier:@"com.apple.Safari"]
lastObject];
pid_t appPID = [runningApp processIdentifier];
//Create event target.
NSAppleEventDescriptor* targetDescriptor
= [NSAppleEventDescriptor descriptorWithDescriptorType:typeKernelProcessID
bytes:&appPID
length:sizeof(appPID)];
//Create "reopen" event.
NSAppleEventDescriptor* reopenDescriptor
= [NSAppleEventDescriptor appleEventWithEventClass:kCoreEventClass
eventID:kAEReopenApplication
targetDescriptor:targetDescriptor
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
//Create "activate" event.
NSAppleEventDescriptor* activateDescriptor
= [NSAppleEventDescriptor appleEventWithEventClass:kAEMiscStandards
eventID:kAEActivate
targetDescriptor:targetDescriptor
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
//Send "activate" followed by "reopen".
AESendMessage([activateDescriptor aeDesc], NULL, kAENoReply, kAEDefaultTimeout);
AESendMessage([reopenDescriptor aeDesc], NULL, kAENoReply, kAEDefaultTimeout);
There may be a better way, but it works.