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 6c0e14fc3332c27309c83137cff9f060ed306aea..2f77af0cafbc0122603bc2735f6327e2e42a07b6 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -24,10 +24,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 {
 
@@ -94,21 +96,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 {
