Mercurial > emacs
comparison src/process.c @ 69873:2d844bbbccd4
* process.h (struct Lisp_Process): Replace Lisp_Objects `pid',
`raw_status_high', and `raw_status_low' with plain integers, and move
them to the end of the structure.
* alloc.c (allocate_process): Use PSEUDOVECSIZE to initialize the
pseudovector's size field so only the Lisp_Object fields get GC'd.
* process.c (update_status, make_process, Fdelete_process)
(Fprocess_status, list_processes_1, start_process_unwind)
(create_process, Fmake_network_process, server_accept_connection)
(wait_reading_process_output, send_process, Fprocess_running_child_p)
(process_send_signal, proc_encode_coding_system, Fprocess_send_eof)
(sigchld_handler, status_notify): Adjust to new non-Lisp fields for
`pid' and `raw_status'.
(Fprocess_id, Fsignal_process): Same, and additionally use floats when
representing PIDs that are larger than most-positive-fixnum.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sat, 08 Apr 2006 15:07:35 +0000 |
parents | 5633a1931272 |
children | dc4e5cc51e66 81f2d90dee68 65ca8fb66a0d |
comparison
equal
deleted
inserted
replaced
69872:f60a24914ee2 | 69873:2d844bbbccd4 |
---|---|
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 |
3347 p->log = Fplist_get (contact, QClog); | 3347 p->log = Fplist_get (contact, QClog); |
3348 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) | 3348 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) |
3349 p->kill_without_query = Qt; | 3349 p->kill_without_query = Qt; |
3350 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) | 3350 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) |
3351 p->command = Qt; | 3351 p->command = Qt; |
3352 p->pid = Qnil; | 3352 p->pid = 0; |
3353 XSETINT (p->infd, inch); | 3353 XSETINT (p->infd, inch); |
3354 XSETINT (p->outfd, outch); | 3354 XSETINT (p->outfd, outch); |
3355 if (is_server && socktype == SOCK_STREAM) | 3355 if (is_server && socktype == SOCK_STREAM) |
3356 p->status = Qlisten; | 3356 p->status = Qlisten; |
3357 | 3357 |
4063 | 4063 |
4064 p->buffer = buffer; | 4064 p->buffer = buffer; |
4065 p->sentinel = ps->sentinel; | 4065 p->sentinel = ps->sentinel; |
4066 p->filter = ps->filter; | 4066 p->filter = ps->filter; |
4067 p->command = Qnil; | 4067 p->command = Qnil; |
4068 p->pid = Qnil; | 4068 p->pid = 0; |
4069 XSETINT (p->infd, s); | 4069 XSETINT (p->infd, s); |
4070 XSETINT (p->outfd, s); | 4070 XSETINT (p->outfd, s); |
4071 p->status = Qrun; | 4071 p->status = Qrun; |
4072 | 4072 |
4073 /* Client processes for accepted connections are not stopped initially. */ | 4073 /* Client processes for accepted connections are not stopped initially. */ |
4363 } | 4363 } |
4364 } | 4364 } |
4365 | 4365 |
4366 /* Don't wait for output from a non-running process. Just | 4366 /* Don't wait for output from a non-running process. Just |
4367 read whatever data has already been received. */ | 4367 read whatever data has already been received. */ |
4368 if (wait_proc != 0 && !NILP (wait_proc->raw_status_low)) | 4368 if (wait_proc && wait_proc->raw_status_new) |
4369 update_status (wait_proc); | 4369 update_status (wait_proc); |
4370 if (wait_proc != 0 | 4370 if (wait_proc |
4371 && ! EQ (wait_proc->status, Qrun) | 4371 && ! EQ (wait_proc->status, Qrun) |
4372 && ! EQ (wait_proc->status, Qconnect)) | 4372 && ! EQ (wait_proc->status, Qconnect)) |
4373 { | 4373 { |
4374 int nread, total_nread = 0; | 4374 int nread, total_nread = 0; |
4375 | 4375 |
4749 else | 4749 else |
4750 { | 4750 { |
4751 /* Preserve status of processes already terminated. */ | 4751 /* Preserve status of processes already terminated. */ |
4752 XSETINT (XPROCESS (proc)->tick, ++process_tick); | 4752 XSETINT (XPROCESS (proc)->tick, ++process_tick); |
4753 deactivate_process (proc); | 4753 deactivate_process (proc); |
4754 if (!NILP (XPROCESS (proc)->raw_status_low)) | 4754 if (XPROCESS (proc)->raw_status_new) |
4755 update_status (XPROCESS (proc)); | 4755 update_status (XPROCESS (proc)); |
4756 if (EQ (XPROCESS (proc)->status, Qrun)) | 4756 if (EQ (XPROCESS (proc)->status, Qrun)) |
4757 XPROCESS (proc)->status | 4757 XPROCESS (proc)->status |
4758 = Fcons (Qexit, Fcons (make_number (256), Qnil)); | 4758 = Fcons (Qexit, Fcons (make_number (256), Qnil)); |
4759 } | 4759 } |
5286 | 5286 |
5287 #ifdef VMS | 5287 #ifdef VMS |
5288 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); | 5288 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); |
5289 #endif /* VMS */ | 5289 #endif /* VMS */ |
5290 | 5290 |
5291 if (! NILP (p->raw_status_low)) | 5291 if (p->raw_status_new) |
5292 update_status (p); | 5292 update_status (p); |
5293 if (! EQ (p->status, Qrun)) | 5293 if (! EQ (p->status, Qrun)) |
5294 error ("Process %s not running", SDATA (p->name)); | 5294 error ("Process %s not running", SDATA (p->name)); |
5295 if (XINT (p->outfd) < 0) | 5295 if (XINT (p->outfd) < 0) |
5296 error ("Output file descriptor of %s is closed", SDATA (p->name)); | 5296 error ("Output file descriptor of %s is closed", SDATA (p->name)); |
5550 signal (SIGPIPE, old_sigpipe); | 5550 signal (SIGPIPE, old_sigpipe); |
5551 #ifndef VMS | 5551 #ifndef VMS |
5552 proc = process_sent_to; | 5552 proc = process_sent_to; |
5553 p = XPROCESS (proc); | 5553 p = XPROCESS (proc); |
5554 #endif | 5554 #endif |
5555 p->raw_status_low = Qnil; | 5555 p->raw_status_new = 0; |
5556 p->raw_status_high = Qnil; | |
5557 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); | 5556 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); |
5558 XSETINT (p->tick, ++process_tick); | 5557 XSETINT (p->tick, ++process_tick); |
5559 deactivate_process (proc); | 5558 deactivate_process (proc); |
5560 #ifdef VMS | 5559 #ifdef VMS |
5561 error ("Error writing to process %s; closed it", SDATA (p->name)); | 5560 error ("Error writing to process %s; closed it", SDATA (p->name)); |
5666 error ("Process %s is not active", | 5665 error ("Process %s is not active", |
5667 SDATA (p->name)); | 5666 SDATA (p->name)); |
5668 | 5667 |
5669 gid = emacs_get_tty_pgrp (p); | 5668 gid = emacs_get_tty_pgrp (p); |
5670 | 5669 |
5671 if (gid == XFASTINT (p->pid)) | 5670 if (gid == p->pid) |
5672 return Qnil; | 5671 return Qnil; |
5673 return Qt; | 5672 return Qt; |
5674 } | 5673 } |
5675 | 5674 |
5676 /* send a signal number SIGNO to PROCESS. | 5675 /* send a signal number SIGNO to PROCESS. |
5713 current_group = Qnil; | 5712 current_group = Qnil; |
5714 | 5713 |
5715 /* If we are using pgrps, get a pgrp number and make it negative. */ | 5714 /* If we are using pgrps, get a pgrp number and make it negative. */ |
5716 if (NILP (current_group)) | 5715 if (NILP (current_group)) |
5717 /* Send the signal to the shell's process group. */ | 5716 /* Send the signal to the shell's process group. */ |
5718 gid = XFASTINT (p->pid); | 5717 gid = p->pid; |
5719 else | 5718 else |
5720 { | 5719 { |
5721 #ifdef SIGNALS_VIA_CHARACTERS | 5720 #ifdef SIGNALS_VIA_CHARACTERS |
5722 /* If possible, send signals to the entire pgrp | 5721 /* If possible, send signals to the entire pgrp |
5723 by sending an input character to it. */ | 5722 by sending an input character to it. */ |
5832 gid = emacs_get_tty_pgrp (p); | 5831 gid = emacs_get_tty_pgrp (p); |
5833 | 5832 |
5834 if (gid == -1) | 5833 if (gid == -1) |
5835 /* If we can't get the information, assume | 5834 /* If we can't get the information, assume |
5836 the shell owns the tty. */ | 5835 the shell owns the tty. */ |
5837 gid = XFASTINT (p->pid); | 5836 gid = p->pid; |
5838 | 5837 |
5839 /* It is not clear whether anything really can set GID to -1. | 5838 /* It is not clear whether anything really can set GID to -1. |
5840 Perhaps on some system one of those ioctls can or could do so. | 5839 Perhaps on some system one of those ioctls can or could do so. |
5841 Or perhaps this is vestigial. */ | 5840 Or perhaps this is vestigial. */ |
5842 if (gid == -1) | 5841 if (gid == -1) |
5843 no_pgrp = 1; | 5842 no_pgrp = 1; |
5844 #else /* ! defined (TIOCGPGRP ) */ | 5843 #else /* ! defined (TIOCGPGRP ) */ |
5845 /* Can't select pgrps on this system, so we know that | 5844 /* Can't select pgrps on this system, so we know that |
5846 the child itself heads the pgrp. */ | 5845 the child itself heads the pgrp. */ |
5847 gid = XFASTINT (p->pid); | 5846 gid = p->pid; |
5848 #endif /* ! defined (TIOCGPGRP ) */ | 5847 #endif /* ! defined (TIOCGPGRP ) */ |
5849 | 5848 |
5850 /* If current_group is lambda, and the shell owns the terminal, | 5849 /* If current_group is lambda, and the shell owns the terminal, |
5851 don't send any signal. */ | 5850 don't send any signal. */ |
5852 if (EQ (current_group, Qlambda) && gid == XFASTINT (p->pid)) | 5851 if (EQ (current_group, Qlambda) && gid == p->pid) |
5853 return; | 5852 return; |
5854 } | 5853 } |
5855 | 5854 |
5856 switch (signo) | 5855 switch (signo) |
5857 { | 5856 { |
5858 #ifdef SIGCONT | 5857 #ifdef SIGCONT |
5859 case SIGCONT: | 5858 case SIGCONT: |
5860 p->raw_status_low = Qnil; | 5859 p->raw_status_new = 0; |
5861 p->raw_status_high = Qnil; | |
5862 p->status = Qrun; | 5860 p->status = Qrun; |
5863 XSETINT (p->tick, ++process_tick); | 5861 XSETINT (p->tick, ++process_tick); |
5864 if (!nomsg) | 5862 if (!nomsg) |
5865 status_notify (NULL); | 5863 status_notify (NULL); |
5866 break; | 5864 break; |
5875 send_process (proc, "\031", 1, Qnil); /* ^Y */ | 5873 send_process (proc, "\031", 1, Qnil); /* ^Y */ |
5876 goto whoosh; | 5874 goto whoosh; |
5877 #endif | 5875 #endif |
5878 case SIGKILL: | 5876 case SIGKILL: |
5879 #ifdef VMS | 5877 #ifdef VMS |
5880 sys$forcex (&(XFASTINT (p->pid)), 0, 1); | 5878 sys$forcex (&(p->pid), 0, 1); |
5881 whoosh: | 5879 whoosh: |
5882 #endif | 5880 #endif |
5883 flush_pending_output (XINT (p->infd)); | 5881 flush_pending_output (XINT (p->infd)); |
5884 break; | 5882 break; |
5885 } | 5883 } |
5887 /* If we don't have process groups, send the signal to the immediate | 5885 /* If we don't have process groups, send the signal to the immediate |
5888 subprocess. That isn't really right, but it's better than any | 5886 subprocess. That isn't really right, but it's better than any |
5889 obvious alternative. */ | 5887 obvious alternative. */ |
5890 if (no_pgrp) | 5888 if (no_pgrp) |
5891 { | 5889 { |
5892 kill (XFASTINT (p->pid), signo); | 5890 kill (p->pid, signo); |
5893 return; | 5891 return; |
5894 } | 5892 } |
5895 | 5893 |
5896 /* gid may be a pid, or minus a pgrp's number */ | 5894 /* gid may be a pid, or minus a pgrp's number */ |
5897 #ifdef TIOCSIGSEND | 5895 #ifdef TIOCSIGSEND |
5900 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) | 5898 if (ioctl (XINT (p->infd), TIOCSIGSEND, signo) == -1) |
5901 EMACS_KILLPG (gid, signo); | 5899 EMACS_KILLPG (gid, signo); |
5902 } | 5900 } |
5903 else | 5901 else |
5904 { | 5902 { |
5905 gid = - XFASTINT (p->pid); | 5903 gid = - p->pid; |
5906 kill (gid, signo); | 5904 kill (gid, signo); |
5907 } | 5905 } |
5908 #else /* ! defined (TIOCSIGSEND) */ | 5906 #else /* ! defined (TIOCSIGSEND) */ |
5909 EMACS_KILLPG (gid, signo); | 5907 EMACS_KILLPG (gid, signo); |
5910 #endif /* ! defined (TIOCSIGSEND) */ | 5908 #endif /* ! defined (TIOCSIGSEND) */ |
6020 this Emacs. | 6018 this Emacs. |
6021 SIGCODE may be an integer, or a symbol whose name is a signal name. */) | 6019 SIGCODE may be an integer, or a symbol whose name is a signal name. */) |
6022 (process, sigcode) | 6020 (process, sigcode) |
6023 Lisp_Object process, sigcode; | 6021 Lisp_Object process, sigcode; |
6024 { | 6022 { |
6025 Lisp_Object pid; | 6023 pid_t pid; |
6026 | 6024 |
6027 if (INTEGERP (process)) | 6025 if (INTEGERP (process)) |
6028 { | 6026 { |
6029 pid = process; | 6027 pid = XINT (process); |
6028 goto got_it; | |
6029 } | |
6030 | |
6031 if (FLOATP (process)) | |
6032 { | |
6033 pid = (pid_t) XFLOAT (process); | |
6030 goto got_it; | 6034 goto got_it; |
6031 } | 6035 } |
6032 | 6036 |
6033 if (STRINGP (process)) | 6037 if (STRINGP (process)) |
6034 { | 6038 { |
6035 Lisp_Object tem; | 6039 Lisp_Object tem; |
6036 if (tem = Fget_process (process), NILP (tem)) | 6040 if (tem = Fget_process (process), NILP (tem)) |
6037 { | 6041 { |
6038 pid = Fstring_to_number (process, make_number (10)); | 6042 pid = XINT (Fstring_to_number (process, make_number (10))); |
6039 if (XINT (pid) != 0) | 6043 if (pid > 0) |
6040 goto got_it; | 6044 goto got_it; |
6041 } | 6045 } |
6042 process = tem; | 6046 process = tem; |
6043 } | 6047 } |
6044 else | 6048 else |
6047 if (NILP (process)) | 6051 if (NILP (process)) |
6048 return process; | 6052 return process; |
6049 | 6053 |
6050 CHECK_PROCESS (process); | 6054 CHECK_PROCESS (process); |
6051 pid = XPROCESS (process)->pid; | 6055 pid = XPROCESS (process)->pid; |
6052 if (!INTEGERP (pid) || XINT (pid) <= 0) | 6056 if (pid <= 0) |
6053 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); | 6057 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); |
6054 | 6058 |
6055 got_it: | 6059 got_it: |
6056 | 6060 |
6057 #define handle_signal(NAME, VALUE) \ | 6061 #define handle_signal(NAME, VALUE) \ |
6166 error ("Undefined signal name %s", name); | 6170 error ("Undefined signal name %s", name); |
6167 } | 6171 } |
6168 | 6172 |
6169 #undef handle_signal | 6173 #undef handle_signal |
6170 | 6174 |
6171 return make_number (kill (XINT (pid), XINT (sigcode))); | 6175 return make_number (kill (pid, XINT (sigcode))); |
6172 } | 6176 } |
6173 | 6177 |
6174 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, | 6178 DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, |
6175 doc: /* Make PROCESS see end-of-file in its input. | 6179 doc: /* Make PROCESS see end-of-file in its input. |
6176 EOF comes after any text already sent to it. | 6180 EOF comes after any text already sent to it. |
6190 | 6194 |
6191 proc = get_process (process); | 6195 proc = get_process (process); |
6192 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; | 6196 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; |
6193 | 6197 |
6194 /* Make sure the process is really alive. */ | 6198 /* Make sure the process is really alive. */ |
6195 if (! NILP (XPROCESS (proc)->raw_status_low)) | 6199 if (XPROCESS (proc)->raw_status_new) |
6196 update_status (XPROCESS (proc)); | 6200 update_status (XPROCESS (proc)); |
6197 if (! EQ (XPROCESS (proc)->status, Qrun)) | 6201 if (! EQ (XPROCESS (proc)->status, Qrun)) |
6198 error ("Process %s not running", SDATA (XPROCESS (proc)->name)); | 6202 error ("Process %s not running", SDATA (XPROCESS (proc)->name)); |
6199 | 6203 |
6200 if (CODING_REQUIRE_FLUSHING (coding)) | 6204 if (CODING_REQUIRE_FLUSHING (coding)) |
6215 #ifdef HAVE_SHUTDOWN | 6219 #ifdef HAVE_SHUTDOWN |
6216 /* If this is a network connection, or socketpair is used | 6220 /* If this is a network connection, or socketpair is used |
6217 for communication with the subprocess, call shutdown to cause EOF. | 6221 for communication with the subprocess, call shutdown to cause EOF. |
6218 (In some old system, shutdown to socketpair doesn't work. | 6222 (In some old system, shutdown to socketpair doesn't work. |
6219 Then we just can't win.) */ | 6223 Then we just can't win.) */ |
6220 if (NILP (XPROCESS (proc)->pid) | 6224 if (XPROCESS (proc)->pid == 0 |
6221 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) | 6225 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) |
6222 shutdown (XINT (XPROCESS (proc)->outfd), 1); | 6226 shutdown (XINT (XPROCESS (proc)->outfd), 1); |
6223 /* In case of socketpair, outfd == infd, so don't close it. */ | 6227 /* In case of socketpair, outfd == infd, so don't close it. */ |
6224 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) | 6228 if (XINT (XPROCESS (proc)->outfd) != XINT (XPROCESS (proc)->infd)) |
6225 emacs_close (XINT (XPROCESS (proc)->outfd)); | 6229 emacs_close (XINT (XPROCESS (proc)->outfd)); |
6352 p = 0; | 6356 p = 0; |
6353 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) | 6357 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) |
6354 { | 6358 { |
6355 proc = XCDR (XCAR (tail)); | 6359 proc = XCDR (XCAR (tail)); |
6356 p = XPROCESS (proc); | 6360 p = XPROCESS (proc); |
6357 if (GC_EQ (p->childp, Qt) && XINT (p->pid) == pid) | 6361 if (GC_EQ (p->childp, Qt) && p->pid == pid) |
6358 break; | 6362 break; |
6359 p = 0; | 6363 p = 0; |
6360 } | 6364 } |
6361 | 6365 |
6362 /* Look for an asynchronous process whose pid hasn't been filled | 6366 /* Look for an asynchronous process whose pid hasn't been filled |
6364 if (p == 0) | 6368 if (p == 0) |
6365 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) | 6369 for (tail = Vprocess_alist; GC_CONSP (tail); tail = XCDR (tail)) |
6366 { | 6370 { |
6367 proc = XCDR (XCAR (tail)); | 6371 proc = XCDR (XCAR (tail)); |
6368 p = XPROCESS (proc); | 6372 p = XPROCESS (proc); |
6369 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1) | 6373 if (p->pid == -1) |
6370 break; | 6374 break; |
6371 p = 0; | 6375 p = 0; |
6372 } | 6376 } |
6373 | 6377 |
6374 /* Change the status of the process that was found. */ | 6378 /* Change the status of the process that was found. */ |
6377 union { int i; WAITTYPE wt; } u; | 6381 union { int i; WAITTYPE wt; } u; |
6378 int clear_desc_flag = 0; | 6382 int clear_desc_flag = 0; |
6379 | 6383 |
6380 XSETINT (p->tick, ++process_tick); | 6384 XSETINT (p->tick, ++process_tick); |
6381 u.wt = w; | 6385 u.wt = w; |
6382 XSETINT (p->raw_status_low, u.i & 0xffff); | 6386 p->raw_status = u.i; |
6383 XSETINT (p->raw_status_high, u.i >> 16); | 6387 p->raw_status_new = 1; |
6384 | 6388 |
6385 /* If process has terminated, stop waiting for its output. */ | 6389 /* If process has terminated, stop waiting for its output. */ |
6386 if ((WIFSIGNALED (w) || WIFEXITED (w)) | 6390 if ((WIFSIGNALED (w) || WIFEXITED (w)) |
6387 && XINT (p->infd) >= 0) | 6391 && XINT (p->infd) >= 0) |
6388 clear_desc_flag = 1; | 6392 clear_desc_flag = 1; |
6575 && read_process_output (proc, XINT (p->infd)) > 0); | 6579 && read_process_output (proc, XINT (p->infd)) > 0); |
6576 | 6580 |
6577 buffer = p->buffer; | 6581 buffer = p->buffer; |
6578 | 6582 |
6579 /* Get the text to use for the message. */ | 6583 /* Get the text to use for the message. */ |
6580 if (!NILP (p->raw_status_low)) | 6584 if (p->raw_status_new) |
6581 update_status (p); | 6585 update_status (p); |
6582 msg = status_message (p); | 6586 msg = status_message (p); |
6583 | 6587 |
6584 /* If process is terminated, deactivate it or delete it. */ | 6588 /* If process is terminated, deactivate it or delete it. */ |
6585 symbol = p->status; | 6589 symbol = p->status; |