From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: michael.cadilhac@lrde.org (=?iso-8859-1?Q?Micha=EBl?= Cadilhac) Newsgroups: gmane.emacs.devel Subject: Re: delete-process bug Date: Tue, 30 May 2006 14:42:59 +0200 Organization: Epita/LRDE Message-ID: <87u0774rak.fsf@lrde.org> References: <87k69eyddj.fsf@lrde.org> <20060524112846.GA12046@agmartin.aq.upm.es> <87bqtmjrsh.fsf_-_@lrde.org> <87odxjakox.fsf@lrde.org> <8764jrlewm.fsf@lrde.org> <87pshyqgtd.fsf@lrde.org> <87fyiuq9t5.fsf@lrde.org> <877j45rj3w.fsf@lrde.org> <87k684y4uz.fsf@lrde.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0341199881==" X-Trace: sea.gmane.org 1148992976 7648 80.91.229.2 (30 May 2006 12:42:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 May 2006 12:42:56 +0000 (UTC) Cc: agustin.martin@hispalinux.es, Eli Zaretskii , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue May 30 14:42:50 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fl3YY-0000ov-Pt for ged-emacs-devel@m.gmane.org; Tue, 30 May 2006 14:42:43 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fl3YY-0005Ve-70 for ged-emacs-devel@m.gmane.org; Tue, 30 May 2006 08:42:42 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fl3YA-0005Uf-Tm for emacs-devel@gnu.org; Tue, 30 May 2006 08:42:19 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fl3Y9-0005UD-DU for emacs-devel@gnu.org; Tue, 30 May 2006 08:42:18 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fl3Y9-0005U6-7w for emacs-devel@gnu.org; Tue, 30 May 2006 08:42:17 -0400 Original-Received: from [62.39.139.2] (helo=kualalumpur.lrde.epita.fr) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Fl3dt-0004cr-U6; Tue, 30 May 2006 08:48:14 -0400 Original-Received: from mahaena.lrde.epita.fr ([192.168.101.66] helo=mahaena.lrde) by kualalumpur.lrde.epita.fr with esmtp (Exim 4.50) id 1Fl3Y1-0002nx-Kg; Tue, 30 May 2006 14:42:09 +0200 Original-To: storm@cua.dk (Kim F. Storm) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEU/JREXDATg1LV8UCao i1fQpmoP3Nd6AAACa0lEQVQ4jWWUQW7jMAxFqZEPICJzAjXeM6W8dyNqX9ji/a8yn04xnWIEJLD9 LJH85DcJFyJV3erqPty8ExHfBikXSdn0WVezC0hOAQiA2nCsAHOqEnPe4k+puU8zw/t+xquqjRKA 4lHsmQBT8C5pDtBwfwH8VdcHI5+FHtjRxrQRwZsf3hNjZRKAPEzHEdH9mFNSYb5dQK3r8KM6ftNy KikAirDZFWdVkDqbxjGFbAcwbQCxxc8mPRHUGOcCIMgMACV23RfJTch3gC6ofT3qCdG0NyUUPfYF yQrKCIAnuYsgX2qPzW2i9sNrfSOSPPZQiygtCNlCjlpXJV38lIKshF/AZzsAMoArdCKNHfXukPuJ ImbLh+9J2gXwap0QpZ7NjZ7ekdkFcDiqPiLGcHmuvaG/AHgy62s52Lae1ABoA7D6d2kDoAvgbnyD ZutEd6lTHOXfYPHVJDH1K8a1+oyrjoZpAGn1x5pfwPr2E9yjxSpk50/gEyKgD/+BD/KzN3tQ13b8 Cx5loF0AgnZf5IUny9hRHQOYBllHDM+6s3oviZBu77mFjDm621Np3hkjR90wE1BkTYvhdDgDgCmR xWChFfcYAOqMm5NZkVWMur8AL5+oeMQOob2FmY76FiM+PrDDZypwGdqokSlAaQOmGH6mW8KpsOwl 0YOLedjSITr6scNRF8D4PesH33QmLrx8AzjpV/3kkg025w2gfAFYKCLluJAc4Ap+h18oo4S8wzaY klDsBUTiY8EZFkg5Iass75FubC9wd8qa0u9+gRxAsAKEaRAo6iB+vwCMGmdBjvgidQGA1ntMX4CS ZYGV/wADyL80LIX/UAAAAABJRU5ErkJggg== In-Reply-To: (Kim F. Storm's message of "Tue, 30 May 2006 14:11:23 +0200") User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:55478 Archived-At: --===============0341199881== Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable storm@cua.dk (Kim F. Storm) writes: > michael.cadilhac@lrde.org (Micha=EBl Cadilhac) writes: > >> It seems that the guard we put (#ifdef SIGCHLD) was not the right >> thing to do, isn't it ? > > I promised Eli to shut up Please don't :-) > but it once again occurred to me that the sigchld_handler is only > called _IF_ SIGCHLD is defined. > Since the sigchld_handler is only installed if SIGCHLD is defined, > it will only ever be called (to cleanup deleted_pid_list) if > SIGCHLD is defined. > So it still seems wrong to put anything on deleted_pid_list unless > SIGCHLD is defined ... > And sigchld_handler should be conditioned by #ifdef SIGCHLD. Aaaand here comes the new new new (super better) new great patch v3923.3 (beta 1) ! --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=process.patch Content-Transfer-Encoding: quoted-printable Index: src/process.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /sources/emacs/emacs/src/process.c,v retrieving revision 1.481 diff -c -r1.481 process.c *** src/process.c 8 May 2006 05:19:42 -0000 1.481 =2D-- src/process.c 30 May 2006 12:35:10 -0000 *************** *** 778,783 **** =2D-- 778,793 ---- return proc; } =20=20 +=20 + #ifdef SIGCHLD + /* Fdelete_process promises to immediately forget about the process, but = in + reality, Emacs needs to remember those processes until they have been + treated by sigchld_handler; otherwise this handler would consider the + process as being synchronous and say that the synchronous process is + dead. */ + static Lisp_Object deleted_pid_list; + #endif +=20 DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0, doc: /* Delete PROCESS: kill it and forget about it immediately. PROCESS may be a process, a buffer, the name of a process or buffer, or *************** *** 799,810 **** } else if (XINT (p->infd) >=3D 0) { ! Fkill_process (process, Qnil); ! /* Do this now, since remove_process will make sigchld_handler do n= othing. */ ! p->status ! =3D Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); ! XSETINT (p->tick, ++process_tick); ! status_notify (p); } remove_process (process); return Qnil; =2D-- 809,839 ---- } else if (XINT (p->infd) >=3D 0) { ! #ifdef SIGCHLD ! Lisp_Object symbol; !=20 ! /* No problem storing the pid here, as it is still in Vprocess_alis= t. */ ! deleted_pid_list =3D Fcons (make_fixnum_or_float (p->pid), ! /* GC treated elements set to nil. */ ! Fdelq (Qnil, deleted_pid_list)); ! /* If the process has already signaled, remove it from the list. */ ! if (p->raw_status_new) ! update_status (p); ! symbol =3D p->status; ! if (CONSP (p->status)) ! symbol =3D XCAR (p->status); ! if (EQ (symbol, Qsignal) || EQ (symbol, Qexit)) ! Fdelete (make_fixnum_or_float (p->pid), deleted_pid_list); ! else ! #endif ! { ! Fkill_process (process, Qnil); ! /* Do this now, since remove_process will make sigchld_handler do noth= ing. */ ! p->status ! =3D Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)); ! XSETINT (p->tick, ++process_tick); ! status_notify (p); ! } } remove_process (process); return Qnil; *************** *** 6316,6321 **** =2D-- 6345,6351 ---- ** Malloc WARNING: This should never call malloc either directly or indirectly; if it does, that is a bug */ =20=20 + #ifdef SIGCHLD SIGTYPE sigchld_handler (signo) int signo; *************** *** 6373,6378 **** =2D-- 6403,6417 ---- =20=20 /* Find the process that signaled us, and record its status. */ =20=20 + /* The process can have been deleted by Fdelete_process. */ + tail =3D Fmember (make_fixnum_or_float (pid), deleted_pid_list); + if (!NILP (tail)) + { + Fsetcar (tail, Qnil); + goto sigchld_end_of_loop; + } +=20 + /* Otherwise, if it is asynchronous, it is in Vprocess_alist. */ p =3D 0; for (tail =3D Vprocess_alist; GC_CONSP (tail); tail =3D XCDR (tail)) { *************** *** 6424,6431 **** EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); } =20=20 ! /* There was no asynchronous process found for that id. Check ! if we have a synchronous process. */ else { synch_process_alive =3D 0; =2D-- 6463,6470 ---- EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); } =20=20 ! /* There was no asynchronous process found for that pid: we have ! a synchronous process. */ else { synch_process_alive =3D 0; *************** *** 6442,6447 **** =2D-- 6481,6490 ---- EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0); } =20=20 +=20 + sigchld_end_of_loop: + ; +=20 /* On some systems, we must return right away. If any more processes want to signal us, we will get another signal. *************** *** 6458,6463 **** =2D-- 6501,6507 ---- #endif /* USG, but not HPUX with WNOHANG */ } } + #endif /* SIGCHLD */ =20=20 static Lisp_Object *************** *** 6843,6848 **** =2D-- 6887,6895 ---- FD_SET (0, &input_wait_mask); =20=20 Vprocess_alist =3D Qnil; + #ifdef SIGCHLD + deleted_pid_list =3D Qnil; + #endif for (i =3D 0; i < MAXDESC; i++) { chan_process[i] =3D Qnil; *************** *** 6981,6986 **** =2D-- 7028,7036 ---- staticpro (&Qlast_nonmenu_event); =20=20 staticpro (&Vprocess_alist); + #ifdef SIGCHLD + staticpro (&deleted_pid_list); + #endif =20=20 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, doc: /* *Non-nil means delete processes immediately when they exi= t. --=-=-= Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable > Sorry that I'm going round in circles (perhaps my brain in an > infinite loop :-) No problem. Hope you will not need a KILL signal in your brain, for the sake of your (?) CHLD. =2D-=20 | Micha=EBl `Micha' Cadilhac | Mieux vaut se taire = | | Epita/LRDE Promo 2007 | Que de parler trop fort. = | | http://www.lrde.org/~cadilh_m | -- As de tr=E8fle = | `-- - JID: micha@amessage.be --' - -= -' --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFEfD3UZYNf4qobZ7kRAjU6AJ0RdacaIQ/p80Seeuq0oynWm8OI+QCgr2+E zpNedAlS2yGLzTv/Gq2mjrE= =hLR5 -----END PGP SIGNATURE----- --==-=-=-- --===============0341199881== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --===============0341199881==--