comparison src/process.c @ 83507:81f2d90dee68

Merged from Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-188 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-189 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-190 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-191 Undo incorrect merge of etc/images/README from Gnus 5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-192 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-193 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-194 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-195 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-196 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-197 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-198 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-199 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-200 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-201 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-202 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-203 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-204 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-205 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-206 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-73 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-74 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-75 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-76 Update from CVS: README: Addition from 5.10.6 tar ball. * emacs@sv.gnu.org/gnus--rel--5.10--patch-77 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-78 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-79 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-80 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-547
author Karoly Lorentey <lorentey@elte.hu>
date Mon, 10 Apr 2006 14:52:24 +0000
parents c1e013e3dc0e 2d844bbbccd4
children 2d2f6f096f6e
comparison
equal deleted inserted replaced
83506:9905fc171253 83507:81f2d90dee68
412 static void 412 static void
413 update_status (p) 413 update_status (p)
414 struct Lisp_Process *p; 414 struct Lisp_Process *p;
415 { 415 {
416 union { int i; WAITTYPE wt; } u; 416 union { int i; WAITTYPE wt; } u;
417 u.i = XFASTINT (p->raw_status_low) + (XFASTINT (p->raw_status_high) << 16); 417 eassert (p->raw_status_new);
418 u.i = p->raw_status;
418 p->status = status_convert (u.wt); 419 p->status = status_convert (u.wt);
419 p->raw_status_low = Qnil; 420 p->raw_status_new = 0;
420 p->raw_status_high = Qnil;
421 } 421 }
422 422
423 /* Convert a process status word in Unix format to 423 /* Convert a process status word in Unix format to
424 the list that we use internally. */ 424 the list that we use internally. */
425 425
617 617
618 p = allocate_process (); 618 p = allocate_process ();
619 619
620 XSETINT (p->infd, -1); 620 XSETINT (p->infd, -1);
621 XSETINT (p->outfd, -1); 621 XSETINT (p->outfd, -1);
622 XSETFASTINT (p->pid, 0);
623 XSETFASTINT (p->tick, 0); 622 XSETFASTINT (p->tick, 0);
624 XSETFASTINT (p->update_tick, 0); 623 XSETFASTINT (p->update_tick, 0);
625 p->raw_status_low = Qnil; 624 p->pid = 0;
626 p->raw_status_high = Qnil; 625 p->raw_status_new = 0;
627 p->status = Qrun; 626 p->status = Qrun;
628 p->mark = Fmake_marker (); 627 p->mark = Fmake_marker ();
629 628
630 #ifdef ADAPTIVE_READ_BUFFERING 629 #ifdef ADAPTIVE_READ_BUFFERING
631 p->adaptive_read_buffering = Qnil; 630 p->adaptive_read_buffering = Qnil;
787 register struct Lisp_Process *p; 786 register struct Lisp_Process *p;
788 787
789 process = get_process (process); 788 process = get_process (process);
790 p = XPROCESS (process); 789 p = XPROCESS (process);
791 790
792 p->raw_status_low = Qnil; 791 p->raw_status_new = 0;
793 p->raw_status_high = Qnil;
794 if (NETCONN1_P (p)) 792 if (NETCONN1_P (p))
795 { 793 {
796 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 794 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
797 XSETINT (p->tick, ++process_tick); 795 XSETINT (p->tick, ++process_tick);
798 status_notify (p); 796 status_notify (p);
838 836
839 if (NILP (process)) 837 if (NILP (process))
840 return process; 838 return process;
841 839
842 p = XPROCESS (process); 840 p = XPROCESS (process);
843 if (!NILP (p->raw_status_low)) 841 if (p->raw_status_new)
844 update_status (p); 842 update_status (p);
845 status = p->status; 843 status = p->status;
846 if (CONSP (status)) 844 if (CONSP (status))
847 status = XCAR (status); 845 status = XCAR (status);
848 if (NETCONN1_P (p)) 846 if (NETCONN1_P (p))
863 If PROCESS has not yet exited or died, return 0. */) 861 If PROCESS has not yet exited or died, return 0. */)
864 (process) 862 (process)
865 register Lisp_Object process; 863 register Lisp_Object process;
866 { 864 {
867 CHECK_PROCESS (process); 865 CHECK_PROCESS (process);
868 if (!NILP (XPROCESS (process)->raw_status_low)) 866 if (XPROCESS (process)->raw_status_new)
869 update_status (XPROCESS (process)); 867 update_status (XPROCESS (process));
870 if (CONSP (XPROCESS (process)->status)) 868 if (CONSP (XPROCESS (process)->status))
871 return XCAR (XCDR (XPROCESS (process)->status)); 869 return XCAR (XCDR (XPROCESS (process)->status));
872 return make_number (0); 870 return make_number (0);
873 } 871 }
878 For a network connection, this value is nil. */) 876 For a network connection, this value is nil. */)
879 (process) 877 (process)
880 register Lisp_Object process; 878 register Lisp_Object process;
881 { 879 {
882 CHECK_PROCESS (process); 880 CHECK_PROCESS (process);
883 return XPROCESS (process)->pid; 881 return (XPROCESS (process)->pid
882 ? make_fixnum_or_float (XPROCESS (process)->pid)
883 : Qnil);
884 } 884 }
885 885
886 DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0, 886 DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0,
887 doc: /* Return the name of PROCESS, as a string. 887 doc: /* Return the name of PROCESS, as a string.
888 This is the name of the program invoked in PROCESS, 888 This is the name of the program invoked in PROCESS,
1360 continue; 1360 continue;
1361 1361
1362 Finsert (1, &p->name); 1362 Finsert (1, &p->name);
1363 Findent_to (i_status, minspace); 1363 Findent_to (i_status, minspace);
1364 1364
1365 if (!NILP (p->raw_status_low)) 1365 if (p->raw_status_new)
1366 update_status (p); 1366 update_status (p);
1367 symbol = p->status; 1367 symbol = p->status;
1368 if (CONSP (p->status)) 1368 if (CONSP (p->status))
1369 symbol = XCAR (p->status); 1369 symbol = XCAR (p->status);
1370 1370
1732 { 1732 {
1733 if (!PROCESSP (proc)) 1733 if (!PROCESSP (proc))
1734 abort (); 1734 abort ();
1735 1735
1736 /* Was PROC started successfully? */ 1736 /* Was PROC started successfully? */
1737 if (XINT (XPROCESS (proc)->pid) <= 0) 1737 if (XPROCESS (proc)->pid <= 0)
1738 remove_process (proc); 1738 remove_process (proc);
1739 1739
1740 return Qnil; 1740 return Qnil;
1741 } 1741 }
1742 1742
1943 to recognize an unknown pid as standing for this process. 1943 to recognize an unknown pid as standing for this process.
1944 It is very important not to let this `marker' value stay 1944 It is very important not to let this `marker' value stay
1945 in the table after this function has returned; if it does 1945 in the table after this function has returned; if it does
1946 it might cause call-process to hang and subsequent asynchronous 1946 it might cause call-process to hang and subsequent asynchronous
1947 processes to get their return values scrambled. */ 1947 processes to get their return values scrambled. */
1948 XSETINT (XPROCESS (process)->pid, -1); 1948 XPROCESS (process)->pid = -1;
1949 1949
1950 BLOCK_INPUT; 1950 BLOCK_INPUT;
1951 1951
1952 { 1952 {
1953 /* child_setup must clobber environ on systems with true vfork. 1953 /* child_setup must clobber environ on systems with true vfork.
2134 emacs_close (forkout); 2134 emacs_close (forkout);
2135 } 2135 }
2136 else 2136 else
2137 { 2137 {
2138 /* vfork succeeded. */ 2138 /* vfork succeeded. */
2139 XSETFASTINT (XPROCESS (process)->pid, pid); 2139 XPROCESS (process)->pid = pid;
2140 2140
2141 #ifdef WINDOWSNT 2141 #ifdef WINDOWSNT
2142 register_child (pid, inchannel); 2142 register_child (pid, inchannel);
2143 #endif /* WINDOWSNT */ 2143 #endif /* WINDOWSNT */
2144 2144
3352 p->log = Fplist_get (contact, QClog); 3352 p->log = Fplist_get (contact, QClog);
3353 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 3353 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3354 p->kill_without_query = Qt; 3354 p->kill_without_query = Qt;
3355 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) 3355 if ((tem = Fplist_get (contact, QCstop), !NILP (tem)))
3356 p->command = Qt; 3356 p->command = Qt;
3357 p->pid = Qnil; 3357 p->pid = 0;
3358 XSETINT (p->infd, inch); 3358 XSETINT (p->infd, inch);
3359 XSETINT (p->outfd, outch); 3359 XSETINT (p->outfd, outch);
3360 if (is_server && socktype == SOCK_STREAM) 3360 if (is_server && socktype == SOCK_STREAM)
3361 p->status = Qlisten; 3361 p->status = Qlisten;
3362 3362
4068 4068
4069 p->buffer = buffer; 4069 p->buffer = buffer;
4070 p->sentinel = ps->sentinel; 4070 p->sentinel = ps->sentinel;
4071 p->filter = ps->filter; 4071 p->filter = ps->filter;
4072 p->command = Qnil; 4072 p->command = Qnil;
4073 p->pid = Qnil; 4073 p->pid = 0;
4074 XSETINT (p->infd, s); 4074 XSETINT (p->infd, s);
4075 XSETINT (p->outfd, s); 4075 XSETINT (p->outfd, s);
4076 p->status = Qrun; 4076 p->status = Qrun;
4077 4077
4078 /* Client processes for accepted connections are not stopped initially. */ 4078 /* Client processes for accepted connections are not stopped initially. */
4368 } 4368 }
4369 } 4369 }
4370 4370
4371 /* Don't wait for output from a non-running process. Just 4371 /* Don't wait for output from a non-running process. Just
4372 read whatever data has already been received. */ 4372 read whatever data has already been received. */
4373 if (wait_proc != 0 && !NILP (wait_proc->raw_status_low)) 4373 if (wait_proc && wait_proc->raw_status_new)
4374 update_status (wait_proc); 4374 update_status (wait_proc);
4375 if (wait_proc != 0 4375 if (wait_proc
4376 && ! EQ (wait_proc->status, Qrun) 4376 && ! EQ (wait_proc->status, Qrun)
4377 && ! EQ (wait_proc->status, Qconnect)) 4377 && ! EQ (wait_proc->status, Qconnect))
4378 { 4378 {
4379 int nread, total_nread = 0; 4379 int nread, total_nread = 0;
4380 4380
4754 else 4754 else
4755 { 4755 {
4756 /* Preserve status of processes already terminated. */ 4756 /* Preserve status of processes already terminated. */
4757 XSETINT (XPROCESS (proc)->tick, ++process_tick); 4757 XSETINT (XPROCESS (proc)->tick, ++process_tick);
4758 deactivate_process (proc); 4758 deactivate_process (proc);
4759 if (!NILP (XPROCESS (proc)->raw_status_low)) 4759 if (XPROCESS (proc)->raw_status_new)
4760 update_status (XPROCESS (proc)); 4760 update_status (XPROCESS (proc));
4761 if (EQ (XPROCESS (proc)->status, Qrun)) 4761 if (EQ (XPROCESS (proc)->status, Qrun))
4762 XPROCESS (proc)->status 4762 XPROCESS (proc)->status
4763 = Fcons (Qexit, Fcons (make_number (256), Qnil)); 4763 = Fcons (Qexit, Fcons (make_number (256), Qnil));
4764 } 4764 }
5291 5291
5292 #ifdef VMS 5292 #ifdef VMS
5293 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); 5293 VMS_PROC_STUFF *vs, *get_vms_process_pointer();
5294 #endif /* VMS */ 5294 #endif /* VMS */
5295 5295
5296 if (! NILP (p->raw_status_low)) 5296 if (p->raw_status_new)
5297 update_status (p); 5297 update_status (p);
5298 if (! EQ (p->status, Qrun)) 5298 if (! EQ (p->status, Qrun))
5299 error ("Process %s not running", SDATA (p->name)); 5299 error ("Process %s not running", SDATA (p->name));
5300 if (XINT (p->outfd) < 0) 5300 if (XINT (p->outfd) < 0)
5301 error ("Output file descriptor of %s is closed", SDATA (p->name)); 5301 error ("Output file descriptor of %s is closed", SDATA (p->name));
5555 signal (SIGPIPE, old_sigpipe); 5555 signal (SIGPIPE, old_sigpipe);
5556 #ifndef VMS 5556 #ifndef VMS
5557 proc = process_sent_to; 5557 proc = process_sent_to;
5558 p = XPROCESS (proc); 5558 p = XPROCESS (proc);
5559 #endif 5559 #endif
5560 p->raw_status_low = Qnil; 5560 p->raw_status_new = 0;
5561 p->raw_status_high = Qnil;
5562 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5561 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil));
5563 XSETINT (p->tick, ++process_tick); 5562 XSETINT (p->tick, ++process_tick);
5564 deactivate_process (proc); 5563 deactivate_process (proc);
5565 #ifdef VMS 5564 #ifdef VMS
5566 error ("Error writing to process %s; closed it", SDATA (p->name)); 5565 error ("Error writing to process %s; closed it", SDATA (p->name));
5671 error ("Process %s is not active", 5670 error ("Process %s is not active",
5672 SDATA (p->name)); 5671 SDATA (p->name));
5673 5672
5674 gid = emacs_get_tty_pgrp (p); 5673 gid = emacs_get_tty_pgrp (p);
5675 5674
5676 if (gid == XFASTINT (p->pid)) 5675 if (gid == p->pid)
5677 return Qnil; 5676 return Qnil;
5678 return Qt; 5677 return Qt;
5679 } 5678 }
5680 5679
5681 /* send a signal number SIGNO to PROCESS. 5680 /* send a signal number SIGNO to PROCESS.
5718 current_group = Qnil; 5717 current_group = Qnil;
5719 5718
5720 /* If we are using pgrps, get a pgrp number and make it negative. */ 5719 /* If we are using pgrps, get a pgrp number and make it negative. */
5721 if (NILP (current_group)) 5720 if (NILP (current_group))
5722 /* Send the signal to the shell's process group. */ 5721 /* Send the signal to the shell's process group. */
5723 gid = XFASTINT (p->pid); 5722 gid = p->pid;
5724 else 5723 else
5725 { 5724 {
5726 #ifdef SIGNALS_VIA_CHARACTERS 5725 #ifdef SIGNALS_VIA_CHARACTERS
5727 /* If possible, send signals to the entire pgrp 5726 /* If possible, send signals to the entire pgrp
5728 by sending an input character to it. */ 5727 by sending an input character to it. */
5837 gid = emacs_get_tty_pgrp (p); 5836 gid = emacs_get_tty_pgrp (p);
5838 5837
5839 if (gid == -1) 5838 if (gid == -1)
5840 /* If we can't get the information, assume 5839 /* If we can't get the information, assume
5841 the shell owns the tty. */ 5840 the shell owns the tty. */
5842 gid = XFASTINT (p->pid); 5841 gid = p->pid;
5843 5842
5844 /* It is not clear whether anything really can set GID to -1. 5843 /* It is not clear whether anything really can set GID to -1.
5845 Perhaps on some system one of those ioctls can or could do so. 5844 Perhaps on some system one of those ioctls can or could do so.
5846 Or perhaps this is vestigial. */ 5845 Or perhaps this is vestigial. */
5847 if (gid == -1) 5846 if (gid == -1)
5848 no_pgrp = 1; 5847 no_pgrp = 1;
5849 #else /* ! defined (TIOCGPGRP ) */ 5848 #else /* ! defined (TIOCGPGRP ) */
5850 /* Can't select pgrps on this system, so we know that 5849 /* Can't select pgrps on this system, so we know that
5851 the child itself heads the pgrp. */ 5850 the child itself heads the pgrp. */
5852 gid = XFASTINT (p->pid); 5851 gid = p->pid;
5853 #endif /* ! defined (TIOCGPGRP ) */ 5852 #endif /* ! defined (TIOCGPGRP ) */
5854 5853
5855 /* If current_group is lambda, and the shell owns the terminal, 5854 /* If current_group is lambda, and the shell owns the terminal,
5856 don't send any signal. */ 5855 don't send any signal. */
5857 if (EQ (current_group, Qlambda) && gid == XFASTINT (p->pid)) 5856 if (EQ (current_group, Qlambda) && gid == p->pid)
5858 return; 5857 return;
5859 } 5858 }
5860 5859
5861 switch (signo) 5860 switch (signo)
5862 { 5861 {
5863 #ifdef SIGCONT 5862 #ifdef SIGCONT
5864 case SIGCONT: 5863 case SIGCONT:
5865 p->raw_status_low = Qnil; 5864 p->raw_status_new = 0;
5866 p->raw_status_high = Qnil;
5867 p->status = Qrun; 5865 p->status = Qrun;
5868 XSETINT (p->tick, ++process_tick); 5866 XSETINT (p->tick, ++process_tick);
5869 if (!nomsg) 5867 if (!nomsg)
5870 status_notify (NULL); 5868 status_notify (NULL);
5871 break; 5869 break;
5880 send_process (proc, "\031", 1, Qnil); /* ^Y */ 5878 send_process (proc, "\031", 1, Qnil); /* ^Y */
5881 goto whoosh; 5879 goto whoosh;
5882 #endif 5880 #endif
5883 case SIGKILL: 5881 case SIGKILL:
5884 #ifdef VMS 5882 #ifdef VMS
5885 sys$forcex (&(XFASTINT (p->pid)), 0, 1); 5883 sys$forcex (&(p->pid), 0, 1);
5886 whoosh: 5884 whoosh:
5887 #endif 5885 #endif
5888 flush_pending_output (XINT (p->infd)); 5886 flush_pending_output (XINT (p->infd));
5889 break; 5887 break;
5890 } 5888 }
5892 /* If we don't have process groups, send the signal to the immediate 5890 /* If we don't have process groups, send the signal to the immediate
5893 subprocess. That isn't really right, but it's better than any 5891 subprocess. That isn't really right, but it's better than any
5894 obvious alternative. */ 5892 obvious alternative. */
5895 if (no_pgrp) 5893 if (no_pgrp)
5896 { 5894 {
5897 kill (XFASTINT (p->pid), signo); 5895 kill (p->pid, signo);
5898 return; 5896 return;
5899 } 5897 }
5900 5898
5901 /* gid may be a pid, or minus a pgrp's number */ 5899 /* gid may be a pid, or minus a pgrp's number */
5902 #ifdef TIOCSIGSEND 5900 #ifdef TIOCSIGSEND
5905 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) 5903 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1)
5906 EMACS_KILLPG (gid, signo); 5904 EMACS_KILLPG (gid, signo);
5907 } 5905 }
5908 else 5906 else
5909 { 5907 {
5910 gid = - XFASTINT (p->pid); 5908 gid = - p->pid;
5911 kill (gid, signo); 5909 kill (gid, signo);
5912 } 5910 }
5913 #else /* ! defined (TIOCSIGSEND) */ 5911 #else /* ! defined (TIOCSIGSEND) */
5914 EMACS_KILLPG (gid, signo); 5912 EMACS_KILLPG (gid, signo);
5915 #endif /* ! defined (TIOCSIGSEND) */ 5913 #endif /* ! defined (TIOCSIGSEND) */
6025 this Emacs. 6023 this Emacs.
6026 SIGCODE may be an integer, or a symbol whose name is a signal name. */) 6024 SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6027 (process, sigcode) 6025 (process, sigcode)
6028 Lisp_Object process, sigcode; 6026 Lisp_Object process, sigcode;
6029 { 6027 {
6030 Lisp_Object pid; 6028 pid_t pid;
6031 6029
6032 if (INTEGERP (process)) 6030 if (INTEGERP (process))
6033 { 6031 {
6034 pid = process; 6032 pid = XINT (process);
6033 goto got_it;
6034 }
6035
6036 if (FLOATP (process))
6037 {
6038 pid = (pid_t) XFLOAT (process);
6035 goto got_it; 6039 goto got_it;
6036 } 6040 }
6037 6041
6038 if (STRINGP (process)) 6042 if (STRINGP (process))
6039 { 6043 {
6040 Lisp_Object tem; 6044 Lisp_Object tem;
6041 if (tem = Fget_process (process), NILP (tem)) 6045 if (tem = Fget_process (process), NILP (tem))
6042 { 6046 {
6043 pid = Fstring_to_number (process, make_number (10)); 6047 pid = XINT (Fstring_to_number (process, make_number (10)));
6044 if (XINT (pid) != 0) 6048 if (pid > 0)
6045 goto got_it; 6049 goto got_it;
6046 } 6050 }
6047 process = tem; 6051 process = tem;
6048 } 6052 }
6049 else 6053 else
6052 if (NILP (process)) 6056 if (NILP (process))
6053 return process; 6057 return process;
6054 6058
6055 CHECK_PROCESS (process); 6059 CHECK_PROCESS (process);
6056 pid = XPROCESS (process)->pid; 6060 pid = XPROCESS (process)->pid;
6057 if (!INTEGERP (pid) || XINT (pid) <= 0) 6061 if (pid <= 0)
6058 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); 6062 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
6059 6063
6060 got_it: 6064 got_it:
6061 6065
6062 #define handle_signal(NAME, VALUE) \ 6066 #define handle_signal(NAME, VALUE) \
6171 error ("Undefined signal name %s", name); 6175 error ("Undefined signal name %s", name);
6172 } 6176 }
6173 6177
6174 #undef handle_signal 6178 #undef handle_signal
6175 6179
6176 return make_number (kill (XINT (pid), XINT (sigcode))); 6180 return make_number (kill (pid, XINT (sigcode)));
6177 } 6181 }
6178 6182
6179 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, 6183 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
6180 doc: /* Make PROCESS see end-of-file in its input. 6184 doc: /* Make PROCESS see end-of-file in its input.
6181 EOF comes after any text already sent to it. 6185 EOF comes after any text already sent to it.
6195 6199
6196 proc = get_process (process); 6200 proc = get_process (process);
6197 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 6201 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
6198 6202
6199 /* Make sure the process is really alive. */ 6203 /* Make sure the process is really alive. */
6200 if (! NILP (XPROCESS (proc)->raw_status_low)) 6204 if (XPROCESS (proc)->raw_status_new)
6201 update_status (XPROCESS (proc)); 6205 update_status (XPROCESS (proc));
6202 if (! EQ (XPROCESS (proc)->status, Qrun)) 6206 if (! EQ (XPROCESS (proc)->status, Qrun))
6203 error ("Process %s not running", SDATA (XPROCESS (proc)->name)); 6207 error ("Process %s not running", SDATA (XPROCESS (proc)->name));
6204 6208
6205 if (CODING_REQUIRE_FLUSHING (coding)) 6209 if (CODING_REQUIRE_FLUSHING (coding))
6220 #ifdef HAVE_SHUTDOWN 6224 #ifdef HAVE_SHUTDOWN
6221 /* If this is a network connection, or socketpair is used 6225 /* If this is a network connection, or socketpair is used
6222 for communication with the subprocess, call shutdown to cause EOF. 6226 for communication with the subprocess, call shutdown to cause EOF.
6223 (In some old system, shutdown to socketpair doesn't work. 6227 (In some old system, shutdown to socketpair doesn't work.
6224 Then we just can't win.) */ 6228 Then we just can't win.) */
6225 if (NILP (XPROCESS (proc)->pid) 6229 if (XPROCESS (proc)->pid == 0
6226 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) 6230 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd))
6227 shutdown (XINT (XPROCESS (proc)->outfd), 1); 6231 shutdown (XINT (XPROCESS (proc)->outfd), 1);
6228 /* In case of socketpair, outfd == infd, so don't close it. */ 6232 /* In case of socketpair, outfd == infd, so don't close it. */
6229 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) 6233 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd))
6230 emacs_close (XINT (XPROCESS (proc)->outfd)); 6234 emacs_close (XINT (XPROCESS (proc)->outfd));
6357 p = 0; 6361 p = 0;
6358 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) 6362 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail))
6359 { 6363 {
6360 proc = XCDR (XCAR (tail)); 6364 proc = XCDR (XCAR (tail));
6361 p = XPROCESS (proc); 6365 p = XPROCESS (proc);
6362 if (GC_EQ (p->childp, Qt) && XINT (p->pid) == pid) 6366 if (GC_EQ (p->childp, Qt) && p->pid == pid)
6363 break; 6367 break;
6364 p = 0; 6368 p = 0;
6365 } 6369 }
6366 6370
6367 /* Look for an asynchronous process whose pid hasn't been filled 6371 /* Look for an asynchronous process whose pid hasn't been filled
6369 if (p == 0) 6373 if (p == 0)
6370 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) 6374 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail))
6371 { 6375 {
6372 proc = XCDR (XCAR (tail)); 6376 proc = XCDR (XCAR (tail));
6373 p = XPROCESS (proc); 6377 p = XPROCESS (proc);
6374 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1) 6378 if (p->pid == -1)
6375 break; 6379 break;
6376 p = 0; 6380 p = 0;
6377 } 6381 }
6378 6382
6379 /* Change the status of the process that was found. */ 6383 /* Change the status of the process that was found. */
6382 union { int i; WAITTYPE wt; } u; 6386 union { int i; WAITTYPE wt; } u;
6383 int clear_desc_flag = 0; 6387 int clear_desc_flag = 0;
6384 6388
6385 XSETINT (p->tick, ++process_tick); 6389 XSETINT (p->tick, ++process_tick);
6386 u.wt = w; 6390 u.wt = w;
6387 XSETINT (p->raw_status_low, u.i & 0xffff); 6391 p->raw_status = u.i;
6388 XSETINT (p->raw_status_high, u.i >> 16); 6392 p->raw_status_new = 1;
6389 6393
6390 /* If process has terminated, stop waiting for its output. */ 6394 /* If process has terminated, stop waiting for its output. */
6391 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6395 if ((WIFSIGNALED (w) || WIFEXITED (w))
6392 && XINT (p->infd) >= 0) 6396 && XINT (p->infd) >= 0)
6393 clear_desc_flag = 1; 6397 clear_desc_flag = 1;
6580 && read_process_output (proc, XINT (p->infd)) > 0); 6584 && read_process_output (proc, XINT (p->infd)) > 0);
6581 6585
6582 buffer = p->buffer; 6586 buffer = p->buffer;
6583 6587
6584 /* Get the text to use for the message. */ 6588 /* Get the text to use for the message. */
6585 if (!NILP (p->raw_status_low)) 6589 if (p->raw_status_new)
6586 update_status (p); 6590 update_status (p);
6587 msg = status_message (p); 6591 msg = status_message (p);
6588 6592
6589 /* If process is terminated, deactivate it or delete it. */ 6593 /* If process is terminated, deactivate it or delete it. */
6590 symbol = p->status; 6594 symbol = p->status;