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.patch

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 d3396d984086717e69d99cff3107ab09506b2b02..237e310b12eb9814f7da9103cf61d69e423b2920 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -27,8 +27,10 @@ extern "C" {
 // 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)
 int pthread_chdir_np(const char* dir) API_AVAILABLE(macosx(10.12));
 int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12));
+#endif
 
 int responsibility_spawnattrs_setdisclaim(posix_spawnattr_t attrs, int disclaim)
     API_AVAILABLE(macosx(10.14));
@@ -96,21 +98,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 {
@@ -230,11 +240,13 @@ Process LaunchProcess(const std::vector<std::string>& argv,
     file_actions.Inherit(STDERR_FILENO);
   }
 
+#if 0
   if (options.disclaim_responsibility) {
     if (__builtin_available(macOS 10.14, *)) {
       DPSXCHECK(responsibility_spawnattrs_setdisclaim(attr.get(), 1));
     }
   }
+#endif
 
   std::vector<char*> argv_cstr;
   argv_cstr.reserve(argv.size() + 1);
