emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Opening a pty without a process


From: Stefan Monnier
Subject: Re: Opening a pty without a process
Date: Tue, 27 Nov 2007 21:21:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (gnu/linux)

>> >> (open-pty-buffer buffer)
-> "/dev/pts/1"
>> 
>> How 'bout:
>> 
>> (defun open-pty-buffer (buffer)
>> (let* ((process-connection-type 'pty)
>> (proc (start-process "foo" buffer "sh" "-c"
>> "while sleep 3600; do :; done")))
>> (process-tty-name proc)))

> In gdb-mi.el (in ELPA) I do:

>  (define-derived-mode gdb-inferior-io-mode comint-mode "Inferior I/O"
>    "Major mode for gdb inferior-io."
>    :syntax-table nil :abbrev-table nil
>    ;; We want to use comint because it has various nifty and familiar
>    ;; features.  We don't need a process, but comint wants one, so create
>    ;; a dummy one.
>    (make-comint-in-buffer
>     "gdb-inferior" (current-buffer) "sleep" nil "1000000000"))

> and then set the terminal for program IO in GDB:

>   (gdb-input
>   ;; Needs GDB 6.4 onwards
>   (list
>     (concat "-inferior-tty-set "
>           (process-tty-name (get-process "gdb-inferior")) "\n")
>           'ignore))

> but it seems a bit of a hack

Yes, I guess `sleep' works as well.

>> I guess it would be convenient indeed to be able to use nil for the
>> program rather than a contraption like the one above.  OTOH we could
>> just use `hexl' by adding a flag to it (it's already abused in a similar
>> way by `ielm').

> Could ielm use a buffer like the one I'm proposing?

No.  It needs "cat" (and used to use "cat").

>> BTW in your patch I do not understand where the create_pty code comes
>> from.  It seems to come from Emacs code, in which case it is code
>> duplication and should be avoided.

> It's almost the first half of create_process.  Sure it would make sense to
> reuse code once it has been agreed that the function is useful.

Please do that,


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]