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 62ffd51c4dd3166d6adbda24e6ee47805a69c93b..398290ffe8dd2d8d2ab13a6877a1932722968255 100644
--- a/base/process/launch_mac.cc
+++ b/base/process/launch_mac.cc
@@ -26,8 +26,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));
@@ -98,21 +100,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 {
@@ -228,11 +238,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);
