Function: tramp-androidsu-handle-make-process
tramp-androidsu-handle-make-process is a byte-compiled function
defined in tramp-androidsu.el.gz.
Signature
(tramp-androidsu-handle-make-process &rest ARGS)
Documentation
Like tramp-handle-make-process, but modified for Android.
Source Code
;; Defined in /usr/src/emacs/lisp/net/tramp-androidsu.el.gz
(defun tramp-androidsu-handle-make-process (&rest args)
"Like `tramp-handle-make-process', but modified for Android."
(tramp-skeleton-make-process args nil nil
(let* ((env (mapcar
(lambda (elt)
(when (tramp-compat-string-search "=" elt) elt))
tramp-remote-process-environment))
;; We use as environment the difference to toplevel
;; `process-environment'.
(env (dolist (elt process-environment env)
(when
(and
(tramp-compat-string-search "=" elt)
(not
(member
elt (default-toplevel-value 'process-environment))))
(setq env (cons elt env)))))
;; Add remote path if exists.
(env (let ((remote-path (string-join (tramp-get-remote-path v) ":")))
(setenv-internal env "PATH" remote-path 'keep)))
(env (setenv-internal env "INSIDE_EMACS" (tramp-inside-emacs) 'keep))
(env (mapcar #'tramp-shell-quote-argument (delq nil env)))
;; Quote command.
(command (mapconcat #'tramp-shell-quote-argument command " "))
;; Set cwd and environment variables.
(command
(append
`("cd" ,(tramp-shell-quote-argument localname) "&&" "(" "env")
env `(,command ")")))
;; Add remote shell if needed.
(command
(if (consp (tramp-get-method-parameter v 'tramp-direct-async))
(append
(tramp-get-method-parameter v 'tramp-direct-async)
`(,(string-join command " ")))
command))
p)
;; Generate a command to start the process using `su' with
;; suitable options for specifying the mount namespace and
;; suchlike.
;; Suppress `internal-default-process-sentinel', which is set
;; when :sentinel is nil. (Bug#71049)
(setq
p (let ((android-use-exec-loader nil))
(make-process
:name name
:buffer buffer
:command
(if (equal user "root")
;; Invoke su in the simplest manner possible, that
;; is to say, without specifying the user, which
;; certain implementations cannot parse when a
;; command is also present, if it may be omitted, so
;; that starting inferior shells on systems with
;; such implementations does not needlessly fail.
(if (tramp-get-connection-property v "remote-namespace")
(append (list "su" "-mm" "-c") command)
(append (list "su" "-c") command))
(if (tramp-get-connection-property v "remote-namespace")
(append (list "su" "-mm" "-" user "-c") command)
(append (list "su" "-" user "-c") command)))
:coding coding
:noquery noquery
:connection-type connection-type
:sentinel (or sentinel #'ignore)
:stderr stderr)))
;; Set filter. Prior Emacs 29.1, it doesn't work reliably to
;; provide it as `make-process' argument when filter is t. See
;; Bug#51177.
(when filter
(set-process-filter p filter))
(tramp-post-process-creation p v)
;; Query flag is overwritten in `tramp-post-process-creation',
;; so we reset it.
(set-process-query-on-exit-flag p (null noquery))
(process-put p 'remote-command orig-command)
(tramp-set-connection-property p "remote-command" orig-command)
(when (bufferp stderr)
(tramp-taint-remote-process-buffer stderr))
p)))