aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKaroly Lorentey2006-06-12 07:27:12 +0000
committerKaroly Lorentey2006-06-12 07:27:12 +0000
commit476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch)
tree4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /src/process.c
parenta13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff)
parent6b519504c3297595101628e823e72c91e562ab45 (diff)
downloademacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz
emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.zip
Merged from emacs@sv.gnu.org.
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-294 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-295 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-296 Update from CVS: admin/FOR-RELEASE: Update refcard section. * emacs@sv.gnu.org/emacs--devo--0--patch-297 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-298 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-299 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-300 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-301 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-302 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-303 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-304 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-103 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-104 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c84
1 files changed, 76 insertions, 8 deletions
diff --git a/src/process.c b/src/process.c
index de4dbd4a3ff..965b33c52c3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -778,6 +778,16 @@ get_process (name)
778 return proc; 778 return proc;
779} 779}
780 780
781
782#ifdef SIGCHLD
783/* Fdelete_process promises to immediately forget about the process, but in
784 reality, Emacs needs to remember those processes until they have been
785 treated by sigchld_handler; otherwise this handler would consider the
786 process as being synchronous and say that the synchronous process is
787 dead. */
788static Lisp_Object deleted_pid_list;
789#endif
790
781DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0, 791DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
782 doc: /* Delete PROCESS: kill it and forget about it immediately. 792 doc: /* Delete PROCESS: kill it and forget about it immediately.
783PROCESS may be a process, a buffer, the name of a process or buffer, or 793PROCESS may be a process, a buffer, the name of a process or buffer, or
@@ -799,12 +809,31 @@ nil, indicating the current buffer's process. */)
799 } 809 }
800 else if (XINT (p->infd) >= 0) 810 else if (XINT (p->infd) >= 0)
801 { 811 {
802 Fkill_process (process, Qnil); 812#ifdef SIGCHLD
803 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 813 Lisp_Object symbol;
804 p->status 814
805 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); 815 /* No problem storing the pid here, as it is still in Vprocess_alist. */
806 XSETINT (p->tick, ++process_tick); 816 deleted_pid_list = Fcons (make_fixnum_or_float (p->pid),
807 status_notify (p); 817 /* GC treated elements set to nil. */
818 Fdelq (Qnil, deleted_pid_list));
819 /* If the process has already signaled, remove it from the list. */
820 if (p->raw_status_new)
821 update_status (p);
822 symbol = p->status;
823 if (CONSP (p->status))
824 symbol = XCAR (p->status);
825 if (EQ (symbol, Qsignal) || EQ (symbol, Qexit))
826 Fdelete (make_fixnum_or_float (p->pid), deleted_pid_list);
827 else
828#endif
829 {
830 Fkill_process (process, Qnil);
831 /* Do this now, since remove_process will make sigchld_handler do nothing. */
832 p->status
833 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil));
834 XSETINT (p->tick, ++process_tick);
835 status_notify (p);
836 }
808 } 837 }
809 remove_process (process); 838 remove_process (process);
810 return Qnil; 839 return Qnil;
@@ -4140,6 +4169,25 @@ wait_reading_process_output_1 ()
4140{ 4169{
4141} 4170}
4142 4171
4172/* Use a wrapper around select to work around a bug in gdb 5.3.
4173 Normally, the wrapper is optimzed away by inlining.
4174
4175 If emacs is stopped inside select, the gdb backtrace doesn't
4176 show the function which called select, so it is practically
4177 impossible to step through wait_reading_process_output. */
4178
4179#ifndef select
4180static INLINE int
4181select_wrapper (n, rfd, wfd, xfd, tmo)
4182 int n;
4183 SELECT_TYPE *rfd, *wfd, *xfd;
4184 EMACS_TIME *tmo;
4185{
4186 return select (n, rfd, wfd, xfd, tmo);
4187}
4188#define select select_wrapper
4189#endif
4190
4143/* Read and dispose of subprocess output while waiting for timeout to 4191/* Read and dispose of subprocess output while waiting for timeout to
4144 elapse and/or keyboard input to be available. 4192 elapse and/or keyboard input to be available.
4145 4193
@@ -6321,6 +6369,7 @@ kill_buffer_processes (buffer)
6321 ** Malloc WARNING: This should never call malloc either directly or 6369 ** Malloc WARNING: This should never call malloc either directly or
6322 indirectly; if it does, that is a bug */ 6370 indirectly; if it does, that is a bug */
6323 6371
6372#ifdef SIGCHLD
6324SIGTYPE 6373SIGTYPE
6325sigchld_handler (signo) 6374sigchld_handler (signo)
6326 int signo; 6375 int signo;
@@ -6378,6 +6427,15 @@ sigchld_handler (signo)
6378 6427
6379 /* Find the process that signaled us, and record its status. */ 6428 /* Find the process that signaled us, and record its status. */
6380 6429
6430 /* The process can have been deleted by Fdelete_process. */
6431 tail = Fmember (make_fixnum_or_float (pid), deleted_pid_list);
6432 if (!NILP (tail))
6433 {
6434 Fsetcar (tail, Qnil);
6435 goto sigchld_end_of_loop;
6436 }
6437
6438 /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */
6381 p = 0; 6439 p = 0;
6382 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) 6440 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail))
6383 { 6441 {
@@ -6429,8 +6487,8 @@ sigchld_handler (signo)
6429 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6487 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
6430 } 6488 }
6431 6489
6432 /* There was no asynchronous process found for that id. Check 6490 /* There was no asynchronous process found for that pid: we have
6433 if we have a synchronous process. */ 6491 a synchronous process. */
6434 else 6492 else
6435 { 6493 {
6436 synch_process_alive = 0; 6494 synch_process_alive = 0;
@@ -6447,6 +6505,9 @@ sigchld_handler (signo)
6447 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); 6505 EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
6448 } 6506 }
6449 6507
6508 sigchld_end_of_loop:
6509 ;
6510
6450 /* On some systems, we must return right away. 6511 /* On some systems, we must return right away.
6451 If any more processes want to signal us, we will 6512 If any more processes want to signal us, we will
6452 get another signal. 6513 get another signal.
@@ -6463,6 +6524,7 @@ sigchld_handler (signo)
6463#endif /* USG, but not HPUX with WNOHANG */ 6524#endif /* USG, but not HPUX with WNOHANG */
6464 } 6525 }
6465} 6526}
6527#endif /* SIGCHLD */
6466 6528
6467 6529
6468static Lisp_Object 6530static Lisp_Object
@@ -6845,6 +6907,9 @@ init_process ()
6845#endif 6907#endif
6846 6908
6847 Vprocess_alist = Qnil; 6909 Vprocess_alist = Qnil;
6910#ifdef SIGCHLD
6911 deleted_pid_list = Qnil;
6912#endif
6848 for (i = 0; i < MAXDESC; i++) 6913 for (i = 0; i < MAXDESC; i++)
6849 { 6914 {
6850 chan_process[i] = Qnil; 6915 chan_process[i] = Qnil;
@@ -6983,6 +7048,9 @@ syms_of_process ()
6983 staticpro (&Qlast_nonmenu_event); 7048 staticpro (&Qlast_nonmenu_event);
6984 7049
6985 staticpro (&Vprocess_alist); 7050 staticpro (&Vprocess_alist);
7051#ifdef SIGCHLD
7052 staticpro (&deleted_pid_list);
7053#endif
6986 7054
6987 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, 7055 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes,
6988 doc: /* *Non-nil means delete processes immediately when they exit. 7056 doc: /* *Non-nil means delete processes immediately when they exit.