aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorMiles Bader2006-04-09 00:38:22 +0000
committerMiles Bader2006-04-09 00:38:22 +0000
commit49d395cd57e646162e7f646a8561a416abacac82 (patch)
treed7fabed45dfc19d6bff30024f82613f372b97951 /src/process.c
parentb6828792a25d042ede1ed164389531e30cc3e202 (diff)
parent1b155fbd766b0a0f78fca5de62dd16a3542883f1 (diff)
downloademacs-49d395cd57e646162e7f646a8561a416abacac82.tar.gz
emacs-49d395cd57e646162e7f646a8561a416abacac82.zip
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-54
Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 190-203) - Update from CVS - Undo incorrect merge of etc/images/README from Gnus 5.10 - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 74-80) - Update from CVS - Update from CVS: README: Addition from 5.10.6 tar ball.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c96
1 files changed, 50 insertions, 46 deletions
diff --git a/src/process.c b/src/process.c
index 9b47f1cae31..eab9daa6bdd 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
@@ -790,8 +789,7 @@ nil, indicating the current buffer's process. */)
790 process = get_process (process); 789 process = get_process (process);
791 p = XPROCESS (process); 790 p = XPROCESS (process);
792 791
793 p->raw_status_low = Qnil; 792 p->raw_status_new = 0;
794 p->raw_status_high = Qnil;
795 if (NETCONN1_P (p)) 793 if (NETCONN1_P (p))
796 { 794 {
797 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 795 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil));
@@ -841,7 +839,7 @@ nil, indicating the current buffer's process. */)
841 return process; 839 return process;
842 840
843 p = XPROCESS (process); 841 p = XPROCESS (process);
844 if (!NILP (p->raw_status_low)) 842 if (p->raw_status_new)
845 update_status (p); 843 update_status (p);
846 status = p->status; 844 status = p->status;
847 if (CONSP (status)) 845 if (CONSP (status))
@@ -866,7 +864,7 @@ If PROCESS has not yet exited or died, return 0. */)
866 register Lisp_Object process; 864 register Lisp_Object process;
867{ 865{
868 CHECK_PROCESS (process); 866 CHECK_PROCESS (process);
869 if (!NILP (XPROCESS (process)->raw_status_low)) 867 if (XPROCESS (process)->raw_status_new)
870 update_status (XPROCESS (process)); 868 update_status (XPROCESS (process));
871 if (CONSP (XPROCESS (process)->status)) 869 if (CONSP (XPROCESS (process)->status))
872 return XCAR (XCDR (XPROCESS (process)->status)); 870 return XCAR (XCDR (XPROCESS (process)->status));
@@ -881,7 +879,9 @@ For a network connection, this value is nil. */)
881 register Lisp_Object process; 879 register Lisp_Object process;
882{ 880{
883 CHECK_PROCESS (process); 881 CHECK_PROCESS (process);
884 return XPROCESS (process)->pid; 882 return (XPROCESS (process)->pid
883 ? make_fixnum_or_float (XPROCESS (process)->pid)
884 : Qnil);
885} 885}
886 886
887DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0, 887DEFUN ("process-name", Fprocess_name, Sprocess_name, 1, 1, 0,
@@ -1363,7 +1363,7 @@ list_processes_1 (query_only)
1363 Finsert (1, &p->name); 1363 Finsert (1, &p->name);
1364 Findent_to (i_status, minspace); 1364 Findent_to (i_status, minspace);
1365 1365
1366 if (!NILP (p->raw_status_low)) 1366 if (p->raw_status_new)
1367 update_status (p); 1367 update_status (p);
1368 symbol = p->status; 1368 symbol = p->status;
1369 if (CONSP (p->status)) 1369 if (CONSP (p->status))
@@ -1735,7 +1735,7 @@ start_process_unwind (proc)
1735 abort (); 1735 abort ();
1736 1736
1737 /* Was PROC started successfully? */ 1737 /* Was PROC started successfully? */
1738 if (XINT (XPROCESS (proc)->pid) <= 0) 1738 if (XPROCESS (proc)->pid <= 0)
1739 remove_process (proc); 1739 remove_process (proc);
1740 1740
1741 return Qnil; 1741 return Qnil;
@@ -1946,7 +1946,7 @@ create_process (process, new_argv, current_dir)
1946 in the table after this function has returned; if it does 1946 in the table after this function has returned; if it does
1947 it might cause call-process to hang and subsequent asynchronous 1947 it might cause call-process to hang and subsequent asynchronous
1948 processes to get their return values scrambled. */ 1948 processes to get their return values scrambled. */
1949 XSETINT (XPROCESS (process)->pid, -1); 1949 XPROCESS (process)->pid = -1;
1950 1950
1951 BLOCK_INPUT; 1951 BLOCK_INPUT;
1952 1952
@@ -2137,7 +2137,7 @@ create_process (process, new_argv, current_dir)
2137 else 2137 else
2138 { 2138 {
2139 /* vfork succeeded. */ 2139 /* vfork succeeded. */
2140 XSETFASTINT (XPROCESS (process)->pid, pid); 2140 XPROCESS (process)->pid = pid;
2141 2141
2142#ifdef WINDOWSNT 2142#ifdef WINDOWSNT
2143 register_child (pid, inchannel); 2143 register_child (pid, inchannel);
@@ -3350,7 +3350,7 @@ usage: (make-network-process &rest ARGS) */)
3350 p->kill_without_query = Qt; 3350 p->kill_without_query = Qt;
3351 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) 3351 if ((tem = Fplist_get (contact, QCstop), !NILP (tem)))
3352 p->command = Qt; 3352 p->command = Qt;
3353 p->pid = Qnil; 3353 p->pid = 0;
3354 XSETINT (p->infd, inch); 3354 XSETINT (p->infd, inch);
3355 XSETINT (p->outfd, outch); 3355 XSETINT (p->outfd, outch);
3356 if (is_server && socktype == SOCK_STREAM) 3356 if (is_server && socktype == SOCK_STREAM)
@@ -4066,7 +4066,7 @@ server_accept_connection (server, channel)
4066 p->sentinel = ps->sentinel; 4066 p->sentinel = ps->sentinel;
4067 p->filter = ps->filter; 4067 p->filter = ps->filter;
4068 p->command = Qnil; 4068 p->command = Qnil;
4069 p->pid = Qnil; 4069 p->pid = 0;
4070 XSETINT (p->infd, s); 4070 XSETINT (p->infd, s);
4071 XSETINT (p->outfd, s); 4071 XSETINT (p->outfd, s);
4072 p->status = Qrun; 4072 p->status = Qrun;
@@ -4366,9 +4366,9 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4366 4366
4367 /* Don't wait for output from a non-running process. Just 4367 /* Don't wait for output from a non-running process. Just
4368 read whatever data has already been received. */ 4368 read whatever data has already been received. */
4369 if (wait_proc != 0 && !NILP (wait_proc->raw_status_low)) 4369 if (wait_proc && wait_proc->raw_status_new)
4370 update_status (wait_proc); 4370 update_status (wait_proc);
4371 if (wait_proc != 0 4371 if (wait_proc
4372 && ! EQ (wait_proc->status, Qrun) 4372 && ! EQ (wait_proc->status, Qrun)
4373 && ! EQ (wait_proc->status, Qconnect)) 4373 && ! EQ (wait_proc->status, Qconnect))
4374 { 4374 {
@@ -4752,7 +4752,7 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display,
4752 /* Preserve status of processes already terminated. */ 4752 /* Preserve status of processes already terminated. */
4753 XSETINT (XPROCESS (proc)->tick, ++process_tick); 4753 XSETINT (XPROCESS (proc)->tick, ++process_tick);
4754 deactivate_process (proc); 4754 deactivate_process (proc);
4755 if (!NILP (XPROCESS (proc)->raw_status_low)) 4755 if (XPROCESS (proc)->raw_status_new)
4756 update_status (XPROCESS (proc)); 4756 update_status (XPROCESS (proc));
4757 if (EQ (XPROCESS (proc)->status, Qrun)) 4757 if (EQ (XPROCESS (proc)->status, Qrun))
4758 XPROCESS (proc)->status 4758 XPROCESS (proc)->status
@@ -5293,7 +5293,7 @@ send_process (proc, buf, len, object)
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));
@@ -5550,8 +5550,7 @@ send_process (proc, buf, len, object)
5550 proc = process_sent_to; 5550 proc = process_sent_to;
5551 p = XPROCESS (proc); 5551 p = XPROCESS (proc);
5552#endif 5552#endif
5553 p->raw_status_low = Qnil; 5553 p->raw_status_new = 0;
5554 p->raw_status_high = Qnil;
5555 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5554 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil));
5556 XSETINT (p->tick, ++process_tick); 5555 XSETINT (p->tick, ++process_tick);
5557 deactivate_process (proc); 5556 deactivate_process (proc);
@@ -5666,7 +5665,7 @@ return t unconditionally. */)
5666 5665
5667 gid = emacs_get_tty_pgrp (p); 5666 gid = emacs_get_tty_pgrp (p);
5668 5667
5669 if (gid == XFASTINT (p->pid)) 5668 if (gid == p->pid)
5670 return Qnil; 5669 return Qnil;
5671 return Qt; 5670 return Qt;
5672} 5671}
@@ -5713,7 +5712,7 @@ process_send_signal (process, signo, current_group, nomsg)
5713 /* If we are using pgrps, get a pgrp number and make it negative. */ 5712 /* If we are using pgrps, get a pgrp number and make it negative. */
5714 if (NILP (current_group)) 5713 if (NILP (current_group))
5715 /* Send the signal to the shell's process group. */ 5714 /* Send the signal to the shell's process group. */
5716 gid = XFASTINT (p->pid); 5715 gid = p->pid;
5717 else 5716 else
5718 { 5717 {
5719#ifdef SIGNALS_VIA_CHARACTERS 5718#ifdef SIGNALS_VIA_CHARACTERS
@@ -5832,7 +5831,7 @@ process_send_signal (process, signo, current_group, nomsg)
5832 if (gid == -1) 5831 if (gid == -1)
5833 /* If we can't get the information, assume 5832 /* If we can't get the information, assume
5834 the shell owns the tty. */ 5833 the shell owns the tty. */
5835 gid = XFASTINT (p->pid); 5834 gid = p->pid;
5836 5835
5837 /* It is not clear whether anything really can set GID to -1. 5836 /* It is not clear whether anything really can set GID to -1.
5838 Perhaps on some system one of those ioctls can or could do so. 5837 Perhaps on some system one of those ioctls can or could do so.
@@ -5842,12 +5841,12 @@ process_send_signal (process, signo, current_group, nomsg)
5842#else /* ! defined (TIOCGPGRP ) */ 5841#else /* ! defined (TIOCGPGRP ) */
5843 /* Can't select pgrps on this system, so we know that 5842 /* Can't select pgrps on this system, so we know that
5844 the child itself heads the pgrp. */ 5843 the child itself heads the pgrp. */
5845 gid = XFASTINT (p->pid); 5844 gid = p->pid;
5846#endif /* ! defined (TIOCGPGRP ) */ 5845#endif /* ! defined (TIOCGPGRP ) */
5847 5846
5848 /* If current_group is lambda, and the shell owns the terminal, 5847 /* If current_group is lambda, and the shell owns the terminal,
5849 don't send any signal. */ 5848 don't send any signal. */
5850 if (EQ (current_group, Qlambda) && gid == XFASTINT (p->pid)) 5849 if (EQ (current_group, Qlambda) && gid == p->pid)
5851 return; 5850 return;
5852 } 5851 }
5853 5852
@@ -5855,8 +5854,7 @@ process_send_signal (process, signo, current_group, nomsg)
5855 { 5854 {
5856#ifdef SIGCONT 5855#ifdef SIGCONT
5857 case SIGCONT: 5856 case SIGCONT:
5858 p->raw_status_low = Qnil; 5857 p->raw_status_new = 0;
5859 p->raw_status_high = Qnil;
5860 p->status = Qrun; 5858 p->status = Qrun;
5861 XSETINT (p->tick, ++process_tick); 5859 XSETINT (p->tick, ++process_tick);
5862 if (!nomsg) 5860 if (!nomsg)
@@ -5875,7 +5873,7 @@ process_send_signal (process, signo, current_group, nomsg)
5875#endif 5873#endif
5876 case SIGKILL: 5874 case SIGKILL:
5877#ifdef VMS 5875#ifdef VMS
5878 sys$forcex (&(XFASTINT (p->pid)), 0, 1); 5876 sys$forcex (&(p->pid), 0, 1);
5879 whoosh: 5877 whoosh:
5880#endif 5878#endif
5881 flush_pending_output (XINT (p->infd)); 5879 flush_pending_output (XINT (p->infd));
@@ -5887,7 +5885,7 @@ process_send_signal (process, signo, current_group, nomsg)
5887 obvious alternative. */ 5885 obvious alternative. */
5888 if (no_pgrp) 5886 if (no_pgrp)
5889 { 5887 {
5890 kill (XFASTINT (p->pid), signo); 5888 kill (p->pid, signo);
5891 return; 5889 return;
5892 } 5890 }
5893 5891
@@ -5900,7 +5898,7 @@ process_send_signal (process, signo, current_group, nomsg)
5900 } 5898 }
5901 else 5899 else
5902 { 5900 {
5903 gid = - XFASTINT (p->pid); 5901 gid = - p->pid;
5904 kill (gid, signo); 5902 kill (gid, signo);
5905 } 5903 }
5906#else /* ! defined (TIOCSIGSEND) */ 5904#else /* ! defined (TIOCSIGSEND) */
@@ -6020,11 +6018,17 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6020 (process, sigcode) 6018 (process, sigcode)
6021 Lisp_Object process, sigcode; 6019 Lisp_Object process, sigcode;
6022{ 6020{
6023 Lisp_Object pid; 6021 pid_t pid;
6024 6022
6025 if (INTEGERP (process)) 6023 if (INTEGERP (process))
6026 { 6024 {
6027 pid = process; 6025 pid = XINT (process);
6026 goto got_it;
6027 }
6028
6029 if (FLOATP (process))
6030 {
6031 pid = (pid_t) XFLOAT (process);
6028 goto got_it; 6032 goto got_it;
6029 } 6033 }
6030 6034
@@ -6033,8 +6037,8 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6033 Lisp_Object tem; 6037 Lisp_Object tem;
6034 if (tem = Fget_process (process), NILP (tem)) 6038 if (tem = Fget_process (process), NILP (tem))
6035 { 6039 {
6036 pid = Fstring_to_number (process, make_number (10)); 6040 pid = XINT (Fstring_to_number (process, make_number (10)));
6037 if (XINT (pid) != 0) 6041 if (pid > 0)
6038 goto got_it; 6042 goto got_it;
6039 } 6043 }
6040 process = tem; 6044 process = tem;
@@ -6047,7 +6051,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6047 6051
6048 CHECK_PROCESS (process); 6052 CHECK_PROCESS (process);
6049 pid = XPROCESS (process)->pid; 6053 pid = XPROCESS (process)->pid;
6050 if (!INTEGERP (pid) || XINT (pid) <= 0) 6054 if (pid <= 0)
6051 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); 6055 error ("Cannot signal process %s", SDATA (XPROCESS (process)->name));
6052 6056
6053 got_it: 6057 got_it:
@@ -6166,7 +6170,7 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */)
6166 6170
6167#undef handle_signal 6171#undef handle_signal
6168 6172
6169 return make_number (kill (XINT (pid), XINT (sigcode))); 6173 return make_number (kill (pid, XINT (sigcode)));
6170} 6174}
6171 6175
6172DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0, 6176DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
@@ -6190,7 +6194,7 @@ text to PROCESS after you call this function. */)
6190 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 6194 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
6191 6195
6192 /* Make sure the process is really alive. */ 6196 /* Make sure the process is really alive. */
6193 if (! NILP (XPROCESS (proc)->raw_status_low)) 6197 if (XPROCESS (proc)->raw_status_new)
6194 update_status (XPROCESS (proc)); 6198 update_status (XPROCESS (proc));
6195 if (! EQ (XPROCESS (proc)->status, Qrun)) 6199 if (! EQ (XPROCESS (proc)->status, Qrun))
6196 error ("Process %s not running", SDATA (XPROCESS (proc)->name)); 6200 error ("Process %s not running", SDATA (XPROCESS (proc)->name));
@@ -6215,7 +6219,7 @@ text to PROCESS after you call this function. */)
6215 for communication with the subprocess, call shutdown to cause EOF. 6219 for communication with the subprocess, call shutdown to cause EOF.
6216 (In some old system, shutdown to socketpair doesn't work. 6220 (In some old system, shutdown to socketpair doesn't work.
6217 Then we just can't win.) */ 6221 Then we just can't win.) */
6218 if (NILP (XPROCESS (proc)->pid) 6222 if (XPROCESS (proc)->pid == 0
6219 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd)) 6223 || XINT (XPROCESS (proc)->outfd) == XINT (XPROCESS (proc)->infd))
6220 shutdown (XINT (XPROCESS (proc)->outfd), 1); 6224 shutdown (XINT (XPROCESS (proc)->outfd), 1);
6221 /* In case of socketpair, outfd == infd, so don't close it. */ 6225 /* In case of socketpair, outfd == infd, so don't close it. */
@@ -6352,7 +6356,7 @@ sigchld_handler (signo)
6352 { 6356 {
6353 proc = XCDR (XCAR (tail)); 6357 proc = XCDR (XCAR (tail));
6354 p = XPROCESS (proc); 6358 p = XPROCESS (proc);
6355 if (GC_EQ (p->childp, Qt) && XINT (p->pid) == pid) 6359 if (GC_EQ (p->childp, Qt) && p->pid == pid)
6356 break; 6360 break;
6357 p = 0; 6361 p = 0;
6358 } 6362 }
@@ -6364,7 +6368,7 @@ sigchld_handler (signo)
6364 { 6368 {
6365 proc = XCDR (XCAR (tail)); 6369 proc = XCDR (XCAR (tail));
6366 p = XPROCESS (proc); 6370 p = XPROCESS (proc);
6367 if (GC_INTEGERP (p->pid) && XINT (p->pid) == -1) 6371 if (p->pid == -1)
6368 break; 6372 break;
6369 p = 0; 6373 p = 0;
6370 } 6374 }
@@ -6377,8 +6381,8 @@ sigchld_handler (signo)
6377 6381
6378 XSETINT (p->tick, ++process_tick); 6382 XSETINT (p->tick, ++process_tick);
6379 u.wt = w; 6383 u.wt = w;
6380 XSETINT (p->raw_status_low, u.i & 0xffff); 6384 p->raw_status = u.i;
6381 XSETINT (p->raw_status_high, u.i >> 16); 6385 p->raw_status_new = 1;
6382 6386
6383 /* If process has terminated, stop waiting for its output. */ 6387 /* If process has terminated, stop waiting for its output. */
6384 if ((WIFSIGNALED (w) || WIFEXITED (w)) 6388 if ((WIFSIGNALED (w) || WIFEXITED (w))
@@ -6575,7 +6579,7 @@ status_notify (deleting_process)
6575 buffer = p->buffer; 6579 buffer = p->buffer;
6576 6580
6577 /* Get the text to use for the message. */ 6581 /* Get the text to use for the message. */
6578 if (!NILP (p->raw_status_low)) 6582 if (p->raw_status_new)
6579 update_status (p); 6583 update_status (p);
6580 msg = status_message (p); 6584 msg = status_message (p);
6581 6585