Subject: 28.0.50; Spawning an emacs process using call-process results in inconsistent behavior between GNU/Linux and macOS

From: Raj Krishnan <[email-masked]>
Date: Sat, 22 May 2021 11:00:43 +0530

Steps for reproduction:
1. Run =emacs -Q= in some directory outside the user's home directory
2. Check the value of the variable =default-directory=, and verify that
   it matches the directory you started emacs in
3. Create an emacs child process using:

#+begin_src emacs_lisp
  (call-process
    (file-truename (expand-file-name invocation-name invocation-directory))
    nil nil nil "-Q")
#+end_src

4. In the newly created frame, check the value of the default directory

5. Behavior on GNU/Linux: The directory matches the value shown in (2)
   Behavior on macOS: The default directory has changed to the user's
   home directory

The behavior was spotted when we noticed inconsistent behavior in
[[https://github.com/minad/affe][affe.el]], which was subsequently
reproduced using =emacs -Q=

In GNU Emacs 28.0.50 (build 2, aarch64-apple-darwin20.4.0, NS
appkit-2022.44 Version 11.3.1 (Build 20E241))
 of 2021-05-16 built on localhost
Repository revision: 1b8f013d179e8866819fe53b4708b57e753a08fc
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.3.1

Configured using:
 'configure --with-ns --with-modules --with-gnutls CFLAGS=-O3'

Configured features:
ACL GLIB GNUTLS JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG
RSVG THREADS TOOLKIT_SCROLL_BARS XIM ZLIB

Important settings:
  value of $LC_CTYPE: UTF-8
  value of $LANG: en_IN.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs
eieio-loaddefs password-cache json map text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 50394 13010)
 (symbols 48 6513 1)
 (strings 32 18129 1897)
 (string-bytes 1 601636)
 (vectors 16 12488)
 (vector-slots 8 175753 14592)
 (floats 8 21 50)
 (intervals 56 206 0)
 (buffers 992 11))