diff options
| author | Stefan Monnier | 2006-04-08 15:07:35 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2006-04-08 15:07:35 +0000 |
| commit | 6bfd98e75de5ae13bdceddb7effda6bb41bedf79 (patch) | |
| tree | f2b62be97f00d1c098052376bf531dddb635dfb7 | |
| parent | 67438f773f7ac8f651029661ab9b578b80ba0722 (diff) | |
| download | emacs-6bfd98e75de5ae13bdceddb7effda6bb41bedf79.tar.gz emacs-6bfd98e75de5ae13bdceddb7effda6bb41bedf79.zip | |
* 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.
| -rw-r--r-- | src/ChangeLog | 23 | ||||
| -rw-r--r-- | src/alloc.c | 16 | ||||
| -rw-r--r-- | src/process.c | 96 | ||||
| -rw-r--r-- | src/process.h | 19 |
4 files changed, 98 insertions, 56 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 56957d655b8..54c9b86db08 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,26 @@ | |||
| 1 | 2006-04-08 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * process.h (struct Lisp_Process): Replace Lisp_Objects `pid', | ||
| 4 | `raw_status_high', and `raw_status_low' with plain integers, and move | ||
| 5 | them to the end of the structure. | ||
| 6 | |||
| 7 | * alloc.c (allocate_process): Use PSEUDOVECSIZE to initialize the | ||
| 8 | pseudovector's size field so only the Lisp_Object fields get GC'd. | ||
| 9 | |||
| 10 | * process.c (update_status, make_process, Fdelete_process) | ||
| 11 | (Fprocess_status, list_processes_1, start_process_unwind) | ||
| 12 | (create_process, Fmake_network_process, server_accept_connection) | ||
| 13 | (wait_reading_process_output, send_process, Fprocess_running_child_p) | ||
| 14 | (process_send_signal, proc_encode_coding_system, Fprocess_send_eof) | ||
| 15 | (sigchld_handler, status_notify): Adjust to new non-Lisp fields for | ||
| 16 | `pid' and `raw_status'. | ||
| 17 | (Fprocess_id, Fsignal_process): Same, and additionally use floats when | ||
| 18 | representing PIDs that are larger than most-positive-fixnum. | ||
| 19 | |||
| 20 | * keymap.c (describe_map): Only use XINT if we checked INTEGERP. | ||
| 21 | |||
| 22 | * lisp.h (OFFSETOF, PSEUDOVECSIZE): New macros. | ||
| 23 | |||
| 1 | 2006-04-08 Eli Zaretskii <eliz@gnu.org> | 24 | 2006-04-08 Eli Zaretskii <eliz@gnu.org> |
| 2 | 25 | ||
| 3 | * w32fns.c (Fx_show_tip): Add 3 to the 5th arg of SetWindowPos. | 26 | * w32fns.c (Fx_show_tip): Add 3 to the 5th arg of SetWindowPos. |
diff --git a/src/alloc.c b/src/alloc.c index e3b65c1a4f4..5b42a0016a8 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3003,13 +3003,17 @@ allocate_frame () | |||
| 3003 | struct Lisp_Process * | 3003 | struct Lisp_Process * |
| 3004 | allocate_process () | 3004 | allocate_process () |
| 3005 | { | 3005 | { |
| 3006 | EMACS_INT len = VECSIZE (struct Lisp_Process); | 3006 | /* Memory-footprint of the object in nb of Lisp_Object fields. */ |
| 3007 | struct Lisp_Vector *v = allocate_vectorlike (len, MEM_TYPE_PROCESS); | 3007 | EMACS_INT memlen = VECSIZE (struct Lisp_Process); |
| 3008 | /* Size if we only count the actual Lisp_Object fields (which need to be | ||
| 3009 | traced by the GC). */ | ||
| 3010 | EMACS_INT lisplen = PSEUDOVECSIZE (struct Lisp_Process, pid); | ||
| 3011 | struct Lisp_Vector *v = allocate_vectorlike (memlen, MEM_TYPE_PROCESS); | ||
| 3008 | EMACS_INT i; | 3012 | EMACS_INT i; |
| 3009 | 3013 | ||
| 3010 | for (i = 0; i < len; ++i) | 3014 | for (i = 0; i < lisplen; ++i) |
| 3011 | v->contents[i] = Qnil; | 3015 | v->contents[i] = Qnil; |
| 3012 | v->size = len; | 3016 | v->size = lisplen; |
| 3013 | 3017 | ||
| 3014 | return (struct Lisp_Process *) v; | 3018 | return (struct Lisp_Process *) v; |
| 3015 | } | 3019 | } |
| @@ -5558,6 +5562,10 @@ mark_object (arg) | |||
| 5558 | if (size & PSEUDOVECTOR_FLAG) | 5562 | if (size & PSEUDOVECTOR_FLAG) |
| 5559 | size &= PSEUDOVECTOR_SIZE_MASK; | 5563 | size &= PSEUDOVECTOR_SIZE_MASK; |
| 5560 | 5564 | ||
| 5565 | /* Note that this size is not the memory-footprint size, but only | ||
| 5566 | the number of Lisp_Object fields that we should trace. | ||
| 5567 | The distinction is used e.g. by Lisp_Process which places extra | ||
| 5568 | non-Lisp_Object fields at the end of the structure. */ | ||
| 5561 | for (i = 0; i < size; i++) /* and then mark its elements */ | 5569 | for (i = 0; i < size; i++) /* and then mark its elements */ |
| 5562 | mark_object (ptr->contents[i]); | 5570 | mark_object (ptr->contents[i]); |
| 5563 | } | 5571 | } |
diff --git a/src/process.c b/src/process.c index 66cb227bb0a..08c515d34e0 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -414,10 +414,10 @@ 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 |
| @@ -619,11 +619,10 @@ make_process (name) | |||
| 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 | ||
| @@ -789,8 +788,7 @@ nil, indicating the current buffer's process. */) | |||
| 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)); |
| @@ -840,7 +838,7 @@ nil, indicating the current buffer's 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)) |
| @@ -865,7 +863,7 @@ If PROCESS has not yet exited or died, return 0. */) | |||
| 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)); |
| @@ -880,7 +878,9 @@ For a network connection, this value is nil. */) | |||
| 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, |
| @@ -1362,7 +1362,7 @@ list_processes_1 (query_only) | |||
| 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)) |
| @@ -1734,7 +1734,7 @@ start_process_unwind (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; |
| @@ -1945,7 +1945,7 @@ create_process (process, new_argv, current_dir) | |||
| 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 | ||
| @@ -2136,7 +2136,7 @@ create_process (process, new_argv, current_dir) | |||
| 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); |
| @@ -3349,7 +3349,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 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) |
| @@ -4065,7 +4065,7 @@ server_accept_connection (server, channel) | |||
| 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; |
| @@ -4365,9 +4365,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 | { |
| @@ -4751,7 +4751,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 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 |
| @@ -5288,7 +5288,7 @@ send_process (proc, buf, len, object) | |||
| 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)); |
| @@ -5552,8 +5552,7 @@ send_process (proc, buf, len, object) | |||
| 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); |
| @@ -5668,7 +5667,7 @@ return t unconditionally. */) | |||
| 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 | } |
| @@ -5715,7 +5714,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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 |
| @@ -5834,7 +5833,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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. |
| @@ -5844,12 +5843,12 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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 | ||
| @@ -5857,8 +5856,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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) |
| @@ -5877,7 +5875,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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)); |
| @@ -5889,7 +5887,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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 | ||
| @@ -5902,7 +5900,7 @@ process_send_signal (process, signo, current_group, nomsg) | |||
| 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) */ |
| @@ -6022,11 +6020,17 @@ 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 | ||
| @@ -6035,8 +6039,8 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 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; |
| @@ -6049,7 +6053,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 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: |
| @@ -6168,7 +6172,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 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, |
| @@ -6192,7 +6196,7 @@ text to PROCESS after you call this function. */) | |||
| 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)); |
| @@ -6217,7 +6221,7 @@ text to PROCESS after you call this function. */) | |||
| 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. */ |
| @@ -6354,7 +6358,7 @@ sigchld_handler (signo) | |||
| 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 | } |
| @@ -6366,7 +6370,7 @@ sigchld_handler (signo) | |||
| 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 | } |
| @@ -6379,8 +6383,8 @@ sigchld_handler (signo) | |||
| 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)) |
| @@ -6577,7 +6581,7 @@ status_notify (deleting_process) | |||
| 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 | ||
diff --git a/src/process.h b/src/process.h index 9625556888c..c4b4281fedf 100644 --- a/src/process.h +++ b/src/process.h | |||
| @@ -51,8 +51,6 @@ struct Lisp_Process | |||
| 51 | Lisp_Object log; | 51 | Lisp_Object log; |
| 52 | /* Buffer that output is going to */ | 52 | /* Buffer that output is going to */ |
| 53 | Lisp_Object buffer; | 53 | Lisp_Object buffer; |
| 54 | /* Number of this process */ | ||
| 55 | Lisp_Object pid; | ||
| 56 | /* t if this is a real child process. | 54 | /* t if this is a real child process. |
| 57 | For a net connection, it is a plist based on the arguments to make-network-process. */ | 55 | For a net connection, it is a plist based on the arguments to make-network-process. */ |
| 58 | Lisp_Object childp; | 56 | Lisp_Object childp; |
| @@ -63,10 +61,6 @@ struct Lisp_Process | |||
| 63 | /* Non-nil means kill silently if Emacs is exited. | 61 | /* Non-nil means kill silently if Emacs is exited. |
| 64 | This is the inverse of the `query-on-exit' flag. */ | 62 | This is the inverse of the `query-on-exit' flag. */ |
| 65 | Lisp_Object kill_without_query; | 63 | Lisp_Object kill_without_query; |
| 66 | /* Record the process status in the raw form in which it comes from `wait'. | ||
| 67 | This is to avoid consing in a signal handler. */ | ||
| 68 | Lisp_Object raw_status_low; | ||
| 69 | Lisp_Object raw_status_high; | ||
| 70 | /* Symbol indicating status of process. | 64 | /* Symbol indicating status of process. |
| 71 | This may be a symbol: run, open, or closed. | 65 | This may be a symbol: run, open, or closed. |
| 72 | Or it may be a list, whose car is stop, exit or signal | 66 | Or it may be a list, whose car is stop, exit or signal |
| @@ -112,6 +106,19 @@ struct Lisp_Process | |||
| 112 | Lisp_Object read_output_delay; | 106 | Lisp_Object read_output_delay; |
| 113 | /* Skip reading this process on next read. */ | 107 | /* Skip reading this process on next read. */ |
| 114 | Lisp_Object read_output_skip; | 108 | Lisp_Object read_output_skip; |
| 109 | |||
| 110 | /* After this point, there are no Lisp_Objects any more. */ | ||
| 111 | |||
| 112 | /* Number of this process. | ||
| 113 | allocate_process assumes this is the first non-Lisp_Object field. | ||
| 114 | A value 0 is used for pseudo-processes such as network connections. */ | ||
| 115 | pid_t pid; | ||
| 116 | /* Record the process status in the raw form in which it comes from `wait'. | ||
| 117 | This is to avoid consing in a signal handler. The `raw_status_new' | ||
| 118 | flag indicates that `raw_status' contains a new status that still | ||
| 119 | needs to be synced to `status'. */ | ||
| 120 | int raw_status_new : 1; | ||
| 121 | int raw_status; | ||
| 115 | }; | 122 | }; |
| 116 | 123 | ||
| 117 | /* Every field in the preceding structure except for the first two | 124 | /* Every field in the preceding structure except for the first two |