all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Query about Emacs Process API | Asynchronous processes
@ 2020-07-04 22:42 Narendra Joshi
  2020-07-05 14:29 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Narendra Joshi @ 2020-07-04 22:42 UTC (permalink / raw)
  To: help-gnu-emacs


Hi,

Reading through Emacs Lisp info manual, I found out
[[info:elisp#Asynchronous Processes][info:elisp#Asynchronous Processes]]
that it's possible to create an asynchronous process (let's ignore
network processes for now) without any command at all. For example,

#+begin_src emacs-lisp
(make-process :name "a-pty-process" :command (list nil) :buffer "*a-pty-process-buffer*")
#+end_src

This creates a process with a pseudo terminal. This process is shown by
`list-processes`

#+begin_src 
 Process ▼ PID Status Buffer TTY Thread Command 
a-pty-process   -2      run     *a-pty-process-buffer*    /dev/pts/1   Main         
#+end_src

^ The process ID is a negative number. It makes me think that there is
no real sub-process (OS level) yet. Is that true? If not, what is being
executed by the sub-process?

I am wondering what the use cases are that such a feature serves.   

Thanks,
-- 
Narendra Joshi



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Query about Emacs Process API | Asynchronous processes
  2020-07-04 22:42 Query about Emacs Process API | Asynchronous processes Narendra Joshi
@ 2020-07-05 14:29 ` Eli Zaretskii
  2020-07-05 14:33   ` Narendra Joshi
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2020-07-05 14:29 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Narendra Joshi <narendraj9@gmail.com>
> Date: Sun, 05 Jul 2020 00:42:22 +0200
> 
> #+begin_src emacs-lisp
> (make-process :name "a-pty-process" :command (list nil) :buffer "*a-pty-process-buffer*")
> #+end_src
> 
> This creates a process with a pseudo terminal. This process is shown by
> `list-processes`
> 
> #+begin_src 
>  Process ▼ PID Status Buffer TTY Thread Command 
> a-pty-process   -2      run     *a-pty-process-buffer*    /dev/pts/1   Main         
> #+end_src
> 
> ^ The process ID is a negative number. It makes me think that there is
> no real sub-process (OS level) yet. Is that true? If not, what is being
> executed by the sub-process?

From the ELisp manual:

     :command COMMAND
          Use COMMAND as the command line of the process.  The value
          should be a list starting with the program’s executable file
          name, followed by strings to give to the program as its
          arguments.  If the first element of the list is ‘nil’, Emacs
          opens a new pseudoterminal (pty) and associates its input and
          output with BUFFER, without actually running any program; the
          rest of the list elements are ignored in that case.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Query about Emacs Process API | Asynchronous processes
  2020-07-05 14:29 ` Eli Zaretskii
@ 2020-07-05 14:33   ` Narendra Joshi
  2020-07-05 15:25     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Narendra Joshi @ 2020-07-05 14:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Narendra Joshi <narendraj9@gmail.com>
>> Date: Sun, 05 Jul 2020 00:42:22 +0200
>> 
>> #+begin_src emacs-lisp
>> (make-process :name "a-pty-process" :command (list nil) :buffer "*a-pty-process-buffer*")
>> #+end_src
>> 
>> This creates a process with a pseudo terminal. This process is shown by
>> `list-processes`
>> 
>> #+begin_src 
>>  Process ▼ PID Status Buffer TTY Thread Command 
>> a-pty-process   -2      run     *a-pty-process-buffer*    /dev/pts/1   Main         
>> #+end_src
>> 
>> ^ The process ID is a negative number. It makes me think that there is
>> no real sub-process (OS level) yet. Is that true? If not, what is being
>> executed by the sub-process?
>
> From the ELisp manual:
>
>      :command COMMAND
>           Use COMMAND as the command line of the process.  The value
>           should be a list starting with the program’s executable file
>           name, followed by strings to give to the program as its
>           arguments.  If the first element of the list is ‘nil’, Emacs
>           opens a new pseudoterminal (pty) and associates its input and
>           output with BUFFER, without actually running any program; the
>           rest of the list elements are ignored in that case.
>
I read that section of the manual. I am still not sure what will be the
use cases for this. Where in Emacs (or the package ecosystem) is this
feature being used currently?

Best,
-- 
Narendra Joshi



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Query about Emacs Process API | Asynchronous processes
  2020-07-05 14:33   ` Narendra Joshi
@ 2020-07-05 15:25     ` Stefan Monnier
  2020-07-05 19:13       ` Narendra Joshi
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2020-07-05 15:25 UTC (permalink / raw)
  To: help-gnu-emacs

> I read that section of the manual. I am still not sure what will be the
> use cases for this. Where in Emacs (or the package ecosystem) is this
> feature being used currently?

I think it's used for `ielm`.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Query about Emacs Process API | Asynchronous processes
  2020-07-05 15:25     ` Stefan Monnier
@ 2020-07-05 19:13       ` Narendra Joshi
  2020-07-07 22:26         ` Narendra Joshi
  0 siblings, 1 reply; 6+ messages in thread
From: Narendra Joshi @ 2020-07-05 19:13 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I read that section of the manual. I am still not sure what will be the
>> use cases for this. Where in Emacs (or the package ecosystem) is this
>> feature being used currently?
>
> I think it's used for `ielm`.
>
>         Stefan
>
`ielm` seems to be adding a dummy process to its buffer using either
`cat` or `hexl` binary.

--8<---------------cut here---------------start------------->8---
  ;; A dummy process to keep comint happy. It will never get any input
  (unless (comint-check-proc (current-buffer))
    ;; Was cat, but on non-Unix platforms that might not exist, so
    ;; use hexl instead, which is part of the Emacs distribution.
    (condition-case nil
        (start-process "ielm" (current-buffer) "hexl")
      (file-error (start-process "ielm" (current-buffer) "cat")))
    (set-process-query-on-exit-flag (ielm-process) nil)
    (goto-char (point-max))
--8<---------------cut here---------------end--------------->8---


-- 
Narendra Joshi



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Query about Emacs Process API | Asynchronous processes
  2020-07-05 19:13       ` Narendra Joshi
@ 2020-07-07 22:26         ` Narendra Joshi
  0 siblings, 0 replies; 6+ messages in thread
From: Narendra Joshi @ 2020-07-07 22:26 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Narendra Joshi <narendraj9@gmail.com> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> I read that section of the manual. I am still not sure what will be the
>>> use cases for this. Where in Emacs (or the package ecosystem) is this
>>> feature being used currently?
>>
>> I think it's used for `ielm`.
>>
>>         Stefan
>>
> `ielm` seems to be adding a dummy process to its buffer using either
> `cat` or `hexl` binary.
>
>   ;; A dummy process to keep comint happy. It will never get any input
>   (unless (comint-check-proc (current-buffer))
>     ;; Was cat, but on non-Unix platforms that might not exist, so
>     ;; use hexl instead, which is part of the Emacs distribution.
>     (condition-case nil
>         (start-process "ielm" (current-buffer) "hexl")
>       (file-error (start-process "ielm" (current-buffer) "cat")))
>     (set-process-query-on-exit-flag (ielm-process) nil)
>     (goto-char (point-max))

I, finally, found the reason for adding it. It's being used by
`gdb-mi.el`. I am still not sure how and why because I am not familiar
with `gdb-mi`.

#+begin_src emacs-lisp
;; We want to use comint because it has various nifty and familiar features.
(define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
  "Major mode for gdb inferior-io."
  :syntax-table nil :abbrev-table nil
  (make-comint-in-buffer "gdb-inferior" (current-buffer) nil))
#+end_src

The feature was added to `make-process` for `gdb-mi.el` in this commit: 

#+begin_src vc-git-log-view
850d0752fb8ab02e3ffc80567578f9e9a4cb77f9
Author: Nick Roberts <nickrob@snap.net.nz>
Date:   Thu Aug 13 13:22:55 2009 +0000

    (create_pty): New function.
    (Fstart_process): Use it to allow Emacs to just associate a pty
    with the buffer.  See associated change in gdb-mi.el.
    (list_processes_1): Deal with no program name.
    (start_process_unwind): Use pid == -2 to mean no process.
850d0752fb8ab02e3ffc80567578f9e9a4cb77f9
#+end_src

Best,
-- 
Narendra Joshi



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-07 22:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-04 22:42 Query about Emacs Process API | Asynchronous processes Narendra Joshi
2020-07-05 14:29 ` Eli Zaretskii
2020-07-05 14:33   ` Narendra Joshi
2020-07-05 15:25     ` Stefan Monnier
2020-07-05 19:13       ` Narendra Joshi
2020-07-07 22:26         ` Narendra Joshi

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.