From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <sattard@slack-corp.com>
Date: Mon, 4 Mar 2019 14:46:48 -0800
Subject: fix: disable usage of pthread_fchdir_np and pthread_chdir_np in MAS
 builds

diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc
index c6d5cbbd5417a1b18a6cf94a681de6c671089e35..92d683619e8de505d5172a8ae09e6e67f28da96f 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -25,10 +25,12 @@
 // descriptor. libpthread only exposes a syscall wrapper starting in
 // macOS 10.12, but the system call dates back to macOS 10.5. On older OSes,
 // the syscall is issued directly.
+#if !defined(MAS_BUILD)
 extern "C" {
 int pthread_chdir_np(const char*) API_AVAILABLE(macosx(10.12));
 int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));
 }
+#endif
 
 namespace base {
 
@@ -95,21 +97,29 @@ class PosixSpawnFileActions {
 };
 
 int ChangeCurrentThreadDirectory(const char* path) {
+  #if defined(MAS_BUILD)
+  return syscall(SYS___pthread_chdir, path);
+  #else
   if (__builtin_available(macOS 10.12, *)) {
     return pthread_chdir_np(path);
   } else {
     return syscall(SYS___pthread_chdir, path);
   }
+  #endif
 }
 
 // The recommended way to unset a per-thread cwd is to set a new value to an
 // invalid file descriptor, per libpthread-218.1.3/private/private.h.
 int ResetCurrentThreadDirectory() {
+  #if defined(MAS_BUILD)
+  return syscall(SYS___pthread_fchdir, -1);
+  #else
   if (__builtin_available(macOS 10.12, *)) {
     return pthread_fchdir_np(-1);
   } else {
     return syscall(SYS___pthread_fchdir, -1);
   }
+  #endif
 }
 
 struct GetAppOutputOptions {
