diff options
| author | Karoly Lorentey | 2004-01-03 08:31:14 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-03 08:31:14 +0000 |
| commit | 4d553a13abdadb4bb469bc0b59c003d48066dce5 (patch) | |
| tree | 0b84a435d41801417190e60bf89ffa0305c8c4ac /lisp | |
| parent | b28c910d1f41815fa4744756852d5f2377d28636 (diff) | |
| download | emacs-4d553a13abdadb4bb469bc0b59c003d48066dce5.tar.gz emacs-4d553a13abdadb4bb469bc0b59c003d48066dce5.zip | |
Portability fixes (now it compiles & runs fine on Solaris).
lib-src/emacsclient.c: Removed tty proxy kludge. Emacs should just
use the same terminal as emacsclient.
(ec_get_tty, ec_set_tty, master, pty_name, old_tty, tty, old_tty_valid)
(tty_erase_char, quit_char, flow_control, meta_key, _sobuf, init_tty)
(window_change, reset_tty, init_pty, copy_from_to)
(pty_conversation): Removed.
(window_change_signal): Just forward the signal to Emacs, don't do
anything else.
(init_signals): Don't set handlers for SIGHUP & SIGINT.
(strprefix): New function.
(main): Don't touch the terminal, simply tell its name to Emacs.
lisp/server.el (server-frames): Changed name and semantics to server-ttys.
(server-tty-live-p): New function.
(server-sentinel): Delete the whole tty, not just the frame.
(server-handle-delete-frame): Removed.
(server-handle-delete-tty): New function. Close the client connection if
the tty is deleted.
(server-start): Clean up server-ttys, not server-frames. Set up
delete-tty-after-functions.
(server-process-filter): Set up server-ttys, not server-frames.
Updated protocol for sending our pid to emacsclient.
(server-buffer-done): Don't delete the client process directly, delete
the tty instead, and rely on the delete-tty hook to close the
connection. Otherwise the terminal could be left in a bad state.
src/cm.c (cmputc): Don't abort on write errors.
src/indent.c: #include <stdio.h>, for termchar.h.
src/window.c: Ditto.
src/xfaces.c: Ditto.
src/sysdep.c (init_sigio, reset_sigio, request_sigio)[!SIGIO]
(unrequest_sigio)[!SIGIO]: If SIGIO is not supported, don't do
anything. (For Solaris.)
(init_sys_modes): Moved tty_set_terminal_modes call back to here,
disable window system check.
(reset_sys_modes): Reset the terminal even if X is running.
src/term.c (Vdelete_tty_after_functions): New variable.
(syms_of_term): Initialize it.
(Fdelete_tty): Updated docs.
(delete_tty): Run delete-tty-after-functions.
(term_init): Removed tty_set_terminal_modes call.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-35
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/server.el | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/lisp/server.el b/lisp/server.el index ef9aa47b6bd..7b42d0fe2a9 100644 --- a/lisp/server.el +++ b/lisp/server.el | |||
| @@ -106,10 +106,11 @@ Each element is (CLIENTID BUFFERS...) where CLIENTID is a string | |||
| 106 | that can be given to the server process to identify a client. | 106 | that can be given to the server process to identify a client. |
| 107 | When a buffer is marked as \"done\", it is removed from this list.") | 107 | When a buffer is marked as \"done\", it is removed from this list.") |
| 108 | 108 | ||
| 109 | (defvar server-frames nil | 109 | (defvar server-ttys nil |
| 110 | "List of current server frames. | 110 | "List of current terminal devices used by the server. |
| 111 | Each element is (CLIENTID FRAME) where CLIENTID is a string | 111 | Each element is (CLIENTID TTY) where CLIENTID is a string |
| 112 | that can be given to the server process to identify a client. | 112 | that can be given to the server process to identify a client. |
| 113 | TTY is the name of the tty device. | ||
| 113 | When all the buffers of the client are marked as \"done\", | 114 | When all the buffers of the client are marked as \"done\", |
| 114 | the frame is deleted.") | 115 | the frame is deleted.") |
| 115 | 116 | ||
| @@ -180,6 +181,14 @@ are done with it in the server.") | |||
| 180 | string) | 181 | string) |
| 181 | (or (bolp) (newline))))) | 182 | (or (bolp) (newline))))) |
| 182 | 183 | ||
| 184 | (defun server-tty-live-p (tty) | ||
| 185 | "Return non-nil if the tty device named TTY has a live frame." | ||
| 186 | (let (result) | ||
| 187 | (dolist (frame (frame-list) result) | ||
| 188 | (when (and (eq (frame-live-p frame) t) | ||
| 189 | (equal (frame-tty-name frame) tty)) | ||
| 190 | (setq result t))))) | ||
| 191 | |||
| 183 | (defun server-sentinel (proc msg) | 192 | (defun server-sentinel (proc msg) |
| 184 | (let ((client (assq proc server-clients))) | 193 | (let ((client (assq proc server-clients))) |
| 185 | ;; Remove PROC from the list of clients. | 194 | ;; Remove PROC from the list of clients. |
| @@ -195,22 +204,21 @@ are done with it in the server.") | |||
| 195 | (not server-existing-buffer)) | 204 | (not server-existing-buffer)) |
| 196 | (server-temp-file-p))) | 205 | (server-temp-file-p))) |
| 197 | (kill-buffer (current-buffer))))) | 206 | (kill-buffer (current-buffer))))) |
| 198 | (let ((frame (assq (car client) server-frames))) | 207 | (let ((tty (assq (car client) server-ttys))) |
| 199 | (when frame | 208 | (when tty |
| 200 | (setq server-frames (delq frame server-frames)) | 209 | (setq server-ttys (delq tty server-ttys)) |
| 201 | (when (frame-live-p (cadr frame)) (delete-frame (cadr frame) 'force)))))) | 210 | (when (server-tty-live-p (cadr tty)) |
| 211 | (delete-tty (cadr tty))))))) | ||
| 202 | (server-log (format "Status changed to %s" (process-status proc)) proc)) | 212 | (server-log (format "Status changed to %s" (process-status proc)) proc)) |
| 203 | 213 | ||
| 204 | (defun server-handle-delete-frame (frame) | 214 | (defun server-handle-delete-tty (tty) |
| 205 | (dolist (entry server-frames) | 215 | (dolist (entry server-ttys) |
| 206 | (let ((proc (nth 0 entry)) | 216 | (let ((proc (nth 0 entry)) |
| 207 | (f (nth 1 entry))) | 217 | (term (nth 1 entry))) |
| 208 | (when (eq f frame) | 218 | (when (equal term tty) |
| 209 | (let ((client (assq proc server-clients))) | 219 | (let ((client (assq proc server-clients))) |
| 210 | (if (and (cdr client) (not (yes-or-no-p "Frame has pending buffers; close anyway? "))) | 220 | (setq server-ttys (delq entry server-ttys)) |
| 211 | (error "Frame deletion cancelled") | 221 | (delete-process (car client))))))) |
| 212 | (setq server-frames (delq entry server-frames)) | ||
| 213 | (delete-process (car client)))))))) | ||
| 214 | 222 | ||
| 215 | (defun server-select-display (display) | 223 | (defun server-select-display (display) |
| 216 | ;; If the current frame is on `display' we're all set. | 224 | ;; If the current frame is on `display' we're all set. |
| @@ -280,15 +288,15 @@ Prefix arg means just kill any existing server communications subprocess." | |||
| 280 | (let ((buffer (nth 1 (car server-clients)))) | 288 | (let ((buffer (nth 1 (car server-clients)))) |
| 281 | (server-buffer-done buffer))) | 289 | (server-buffer-done buffer))) |
| 282 | ;; Delete any remaining opened frames of the previous server. | 290 | ;; Delete any remaining opened frames of the previous server. |
| 283 | (while server-frames | 291 | (while server-ttys |
| 284 | (let ((frame (cadar server-frames))) | 292 | (let ((tty (cadar server-ttys))) |
| 285 | (setq server-frames (cdr server-frames)) | 293 | (setq server-ttys (cdr server-ttys)) |
| 286 | (when (frame-live-p frame) (delete-frame frame 'force)))) | 294 | (when (server-tty-live-p tty) (delete-tty tty)))) |
| 287 | (unless leave-dead | 295 | (unless leave-dead |
| 288 | (if server-process | 296 | (if server-process |
| 289 | (server-log (message "Restarting server"))) | 297 | (server-log (message "Restarting server"))) |
| 290 | (letf (((default-file-modes) ?\700)) | 298 | (letf (((default-file-modes) ?\700)) |
| 291 | (add-to-list 'delete-frame-functions 'server-handle-delete-frame) | 299 | (add-to-list 'delete-tty-after-functions 'server-handle-delete-tty) |
| 292 | (setq server-process | 300 | (setq server-process |
| 293 | (make-network-process | 301 | (make-network-process |
| 294 | :name "server" :family 'local :server t :noquery t | 302 | :name "server" :family 'local :server t :noquery t |
| @@ -354,9 +362,9 @@ PROC is the server process. Format of STRING is \"PATH PATH PATH... \\n\"." | |||
| 354 | (setq request (substring request (match-end 0))) | 362 | (setq request (substring request (match-end 0))) |
| 355 | (condition-case err | 363 | (condition-case err |
| 356 | (let ((frame (make-frame-on-tty tty type))) | 364 | (let ((frame (make-frame-on-tty tty type))) |
| 357 | (setq server-frames (cons (list (car client) frame) server-frames)) | 365 | (setq server-ttys (cons (list (car client) (frame-tty-name frame)) server-ttys)) |
| 358 | (sit-for 0) | 366 | (sit-for 0) |
| 359 | (process-send-string proc (concat (number-to-string (emacs-pid)) "\n")) | 367 | (process-send-string proc (concat "emacs-pid " (number-to-string (emacs-pid)) "\n")) |
| 360 | (select-frame frame) | 368 | (select-frame frame) |
| 361 | (setq newframe t)) | 369 | (setq newframe t)) |
| 362 | (error (ignore-errors (process-send-string proc (concat (nth 1 err) "\n"))) | 370 | (error (ignore-errors (process-send-string proc (concat (nth 1 err) "\n"))) |
| @@ -488,9 +496,15 @@ FOR-KILLING if non-nil indicates that we are called from `kill-buffer'." | |||
| 488 | ;; If client now has no pending buffers, | 496 | ;; If client now has no pending buffers, |
| 489 | ;; tell it that it is done, and forget it entirely. | 497 | ;; tell it that it is done, and forget it entirely. |
| 490 | (unless (cdr client) | 498 | (unless (cdr client) |
| 491 | (delete-process (car client)) | 499 | (let ((tty (assq (car client) server-ttys))) |
| 492 | (server-log "Close" (car client)) | 500 | (if tty |
| 493 | (setq server-clients (delq client server-clients)))) | 501 | ;; Be careful, if we delete the process before the |
| 502 | ;; tty, then the terminal modes will not be restored | ||
| 503 | ;; correctly. | ||
| 504 | (delete-tty (cadr tty)) | ||
| 505 | (delete-process (car client)) | ||
| 506 | (server-log "Close" (car client)) | ||
| 507 | (setq server-clients (delq client server-clients)))))) | ||
| 494 | (setq old-clients (cdr old-clients))) | 508 | (setq old-clients (cdr old-clients))) |
| 495 | (if (and (bufferp buffer) (buffer-name buffer)) | 509 | (if (and (bufferp buffer) (buffer-name buffer)) |
| 496 | ;; We may or may not kill this buffer; | 510 | ;; We may or may not kill this buffer; |