1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "MacAutoreleasePool.h"
9 namespace mozilla::MacUtils {
12 * Helper to launch macOS tasks via NSTask and wait for the launched task to
15 void LaunchTask(NSString* aPath, NSArray* aArguments) {
16 MacAutoreleasePool pool;
19 NSTask* task = [[NSTask alloc] init];
20 [task setExecutableURL:[NSURL fileURLWithPath:aPath]];
22 [task setArguments:aArguments];
24 [task launchAndReturnError:nil];
27 } @catch (NSException* e) {
28 NSLog(@"%@: %@", e.name, e.reason);
32 } // namespace mozilla::MacUtils