diff options
| author | Karl Heuer | 1995-05-18 16:54:42 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-05-18 16:54:42 +0000 |
| commit | bf351cc2bead795586b5c4a47ee2146712d7eb79 (patch) | |
| tree | c44989cab77ad6c4f1ef926680f88024f094c016 /src/process.c | |
| parent | c344d4be628e9893d7ed9f0dea87abdd7e64d93c (diff) | |
| download | emacs-bf351cc2bead795586b5c4a47ee2146712d7eb79.tar.gz emacs-bf351cc2bead795586b5c4a47ee2146712d7eb79.zip | |
(status_notify): If Vprocess_alist changes within
the loop, do the whole loop again.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 145 |
1 files changed, 75 insertions, 70 deletions
diff --git a/src/process.c b/src/process.c index 119ed47c749..cedcb38fa8a 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3386,6 +3386,7 @@ status_notify () | |||
| 3386 | register Lisp_Object proc, buffer; | 3386 | register Lisp_Object proc, buffer; |
| 3387 | Lisp_Object tail, msg; | 3387 | Lisp_Object tail, msg; |
| 3388 | struct gcpro gcpro1, gcpro2; | 3388 | struct gcpro gcpro1, gcpro2; |
| 3389 | Lisp_Object old_process_alist; | ||
| 3389 | 3390 | ||
| 3390 | tail = Qnil; | 3391 | tail = Qnil; |
| 3391 | msg = Qnil; | 3392 | msg = Qnil; |
| @@ -3395,87 +3396,91 @@ status_notify () | |||
| 3395 | reference. */ | 3396 | reference. */ |
| 3396 | GCPRO2 (tail, msg); | 3397 | GCPRO2 (tail, msg); |
| 3397 | 3398 | ||
| 3398 | for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail)) | 3399 | do |
| 3399 | { | 3400 | { |
| 3400 | Lisp_Object symbol; | 3401 | old_process_alist = Vprocess_alist; |
| 3401 | register struct Lisp_Process *p; | 3402 | for (tail = Vprocess_alist; !NILP (tail); tail = Fcdr (tail)) |
| 3402 | |||
| 3403 | proc = Fcdr (Fcar (tail)); | ||
| 3404 | p = XPROCESS (proc); | ||
| 3405 | |||
| 3406 | if (XINT (p->tick) != XINT (p->update_tick)) | ||
| 3407 | { | 3403 | { |
| 3408 | XSETINT (p->update_tick, XINT (p->tick)); | 3404 | Lisp_Object symbol; |
| 3405 | register struct Lisp_Process *p; | ||
| 3409 | 3406 | ||
| 3410 | /* If process is still active, read any output that remains. */ | 3407 | proc = Fcdr (Fcar (tail)); |
| 3411 | if (XINT (p->infd) >= 0) | 3408 | p = XPROCESS (proc); |
| 3412 | while (! EQ (p->filter, Qt) | ||
| 3413 | && read_process_output (proc, XINT (p->infd)) > 0); | ||
| 3414 | 3409 | ||
| 3415 | buffer = p->buffer; | 3410 | if (XINT (p->tick) != XINT (p->update_tick)) |
| 3411 | { | ||
| 3412 | XSETINT (p->update_tick, XINT (p->tick)); | ||
| 3416 | 3413 | ||
| 3417 | /* Get the text to use for the message. */ | 3414 | /* If process is still active, read any output that remains. */ |
| 3418 | if (!NILP (p->raw_status_low)) | 3415 | if (XINT (p->infd) >= 0) |
| 3419 | update_status (p); | 3416 | while (! EQ (p->filter, Qt) |
| 3420 | msg = status_message (p->status); | 3417 | && read_process_output (proc, XINT (p->infd)) > 0); |
| 3421 | 3418 | ||
| 3422 | /* If process is terminated, deactivate it or delete it. */ | 3419 | buffer = p->buffer; |
| 3423 | symbol = p->status; | ||
| 3424 | if (CONSP (p->status)) | ||
| 3425 | symbol = XCONS (p->status)->car; | ||
| 3426 | 3420 | ||
| 3427 | if (EQ (symbol, Qsignal) || EQ (symbol, Qexit) | 3421 | /* Get the text to use for the message. */ |
| 3428 | || EQ (symbol, Qclosed)) | 3422 | if (!NILP (p->raw_status_low)) |
| 3429 | { | 3423 | update_status (p); |
| 3430 | if (delete_exited_processes) | 3424 | msg = status_message (p->status); |
| 3431 | remove_process (proc); | ||
| 3432 | else | ||
| 3433 | deactivate_process (proc); | ||
| 3434 | } | ||
| 3435 | 3425 | ||
| 3436 | /* Now output the message suitably. */ | 3426 | /* If process is terminated, deactivate it or delete it. */ |
| 3437 | if (!NILP (p->sentinel)) | 3427 | symbol = p->status; |
| 3438 | exec_sentinel (proc, msg); | 3428 | if (CONSP (p->status)) |
| 3439 | /* Don't bother with a message in the buffer | 3429 | symbol = XCONS (p->status)->car; |
| 3440 | when a process becomes runnable. */ | ||
| 3441 | else if (!EQ (symbol, Qrun) && !NILP (buffer)) | ||
| 3442 | { | ||
| 3443 | Lisp_Object ro, tem; | ||
| 3444 | struct buffer *old = current_buffer; | ||
| 3445 | int opoint; | ||
| 3446 | |||
| 3447 | ro = XBUFFER (buffer)->read_only; | ||
| 3448 | 3430 | ||
| 3449 | /* Avoid error if buffer is deleted | 3431 | if (EQ (symbol, Qsignal) || EQ (symbol, Qexit) |
| 3450 | (probably that's why the process is dead, too) */ | 3432 | || EQ (symbol, Qclosed)) |
| 3451 | if (NILP (XBUFFER (buffer)->name)) | 3433 | { |
| 3452 | continue; | 3434 | if (delete_exited_processes) |
| 3453 | Fset_buffer (buffer); | 3435 | remove_process (proc); |
| 3454 | opoint = point; | 3436 | else |
| 3455 | /* Insert new output into buffer | 3437 | deactivate_process (proc); |
| 3456 | at the current end-of-output marker, | 3438 | } |
| 3457 | thus preserving logical ordering of input and output. */ | ||
| 3458 | if (XMARKER (p->mark)->buffer) | ||
| 3459 | SET_PT (marker_position (p->mark)); | ||
| 3460 | else | ||
| 3461 | SET_PT (ZV); | ||
| 3462 | if (point <= opoint) | ||
| 3463 | opoint += XSTRING (msg)->size + XSTRING (p->name)->size + 10; | ||
| 3464 | |||
| 3465 | tem = current_buffer->read_only; | ||
| 3466 | current_buffer->read_only = Qnil; | ||
| 3467 | insert_string ("\nProcess "); | ||
| 3468 | Finsert (1, &p->name); | ||
| 3469 | insert_string (" "); | ||
| 3470 | Finsert (1, &msg); | ||
| 3471 | current_buffer->read_only = tem; | ||
| 3472 | Fset_marker (p->mark, make_number (point), p->buffer); | ||
| 3473 | 3439 | ||
| 3474 | SET_PT (opoint); | 3440 | /* Now output the message suitably. */ |
| 3475 | set_buffer_internal (old); | 3441 | if (!NILP (p->sentinel)) |
| 3442 | exec_sentinel (proc, msg); | ||
| 3443 | /* Don't bother with a message in the buffer | ||
| 3444 | when a process becomes runnable. */ | ||
| 3445 | else if (!EQ (symbol, Qrun) && !NILP (buffer)) | ||
| 3446 | { | ||
| 3447 | Lisp_Object ro, tem; | ||
| 3448 | struct buffer *old = current_buffer; | ||
| 3449 | int opoint; | ||
| 3450 | |||
| 3451 | ro = XBUFFER (buffer)->read_only; | ||
| 3452 | |||
| 3453 | /* Avoid error if buffer is deleted | ||
| 3454 | (probably that's why the process is dead, too) */ | ||
| 3455 | if (NILP (XBUFFER (buffer)->name)) | ||
| 3456 | continue; | ||
| 3457 | Fset_buffer (buffer); | ||
| 3458 | opoint = point; | ||
| 3459 | /* Insert new output into buffer | ||
| 3460 | at the current end-of-output marker, | ||
| 3461 | thus preserving logical ordering of input and output. */ | ||
| 3462 | if (XMARKER (p->mark)->buffer) | ||
| 3463 | SET_PT (marker_position (p->mark)); | ||
| 3464 | else | ||
| 3465 | SET_PT (ZV); | ||
| 3466 | if (point <= opoint) | ||
| 3467 | opoint += XSTRING (msg)->size + XSTRING (p->name)->size + 10; | ||
| 3468 | |||
| 3469 | tem = current_buffer->read_only; | ||
| 3470 | current_buffer->read_only = Qnil; | ||
| 3471 | insert_string ("\nProcess "); | ||
| 3472 | Finsert (1, &p->name); | ||
| 3473 | insert_string (" "); | ||
| 3474 | Finsert (1, &msg); | ||
| 3475 | current_buffer->read_only = tem; | ||
| 3476 | Fset_marker (p->mark, make_number (point), p->buffer); | ||
| 3477 | |||
| 3478 | SET_PT (opoint); | ||
| 3479 | set_buffer_internal (old); | ||
| 3480 | } | ||
| 3476 | } | 3481 | } |
| 3477 | } | 3482 | } /* end for */ |
| 3478 | } /* end for */ | 3483 | } while (! EQ (old_process_alist, Vprocess_alist)); |
| 3479 | 3484 | ||
| 3480 | update_mode_lines++; /* in case buffers use %s in mode-line-format */ | 3485 | update_mode_lines++; /* in case buffers use %s in mode-line-format */ |
| 3481 | redisplay_preserve_echo_area (); | 3486 | redisplay_preserve_echo_area (); |