aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorTom Tromey2013-03-08 11:57:29 -0700
committerTom Tromey2013-03-08 11:57:29 -0700
commit71f91792e3013b397996905224f387da5cc539a9 (patch)
tree4c3d3ba909e76deea1cdf73b73fca67a57149465 /src/process.c
parent6f4de085f065e11f4df3195d47479f28f5ef08ba (diff)
parentb5426561089d39f18b42bed9dbfcb531f43ed562 (diff)
downloademacs-71f91792e3013b397996905224f387da5cc539a9.tar.gz
emacs-71f91792e3013b397996905224f387da5cc539a9.zip
merge from trunk
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c90
1 files changed, 44 insertions, 46 deletions
diff --git a/src/process.c b/src/process.c
index d56819da67a..044e0c54772 100644
--- a/src/process.c
+++ b/src/process.c
@@ -146,13 +146,13 @@ Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
146Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime; 146Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
147Lisp_Object QCname, QCtype; 147Lisp_Object QCname, QCtype;
148 148
149/* Non-zero if keyboard input is on hold, zero otherwise. */ 149/* True if keyboard input is on hold, zero otherwise. */
150 150
151static int kbd_is_on_hold; 151static bool kbd_is_on_hold;
152 152
153/* Nonzero means don't run process sentinels. This is used 153/* Nonzero means don't run process sentinels. This is used
154 when exiting. */ 154 when exiting. */
155int inhibit_sentinels; 155bool inhibit_sentinels;
156 156
157#ifdef subprocesses 157#ifdef subprocesses
158 158
@@ -180,10 +180,6 @@ static Lisp_Object Qlast_nonmenu_event;
180#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) 180#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
181#define SERIALCONN1_P(p) (EQ (p->type, Qserial)) 181#define SERIALCONN1_P(p) (EQ (p->type, Qserial))
182 182
183#ifndef HAVE_H_ERRNO
184extern int h_errno;
185#endif
186
187/* Number of events of change of status of a process. */ 183/* Number of events of change of status of a process. */
188static EMACS_INT process_tick; 184static EMACS_INT process_tick;
189/* Number of events for which the user or sentinel has been notified. */ 185/* Number of events for which the user or sentinel has been notified. */
@@ -238,9 +234,9 @@ static EMACS_INT update_tick;
238 234
239static int process_output_delay_count; 235static int process_output_delay_count;
240 236
241/* Non-zero if any process has non-nil read_output_skip. */ 237/* True if any process has non-nil read_output_skip. */
242 238
243static int process_output_skip; 239static bool process_output_skip;
244 240
245#else 241#else
246#define process_output_delay_count 0 242#define process_output_delay_count 0
@@ -248,7 +244,7 @@ static int process_output_skip;
248 244
249static void create_process (Lisp_Object, char **, Lisp_Object); 245static void create_process (Lisp_Object, char **, Lisp_Object);
250#ifdef USABLE_SIGIO 246#ifdef USABLE_SIGIO
251static int keyboard_bit_set (SELECT_TYPE *); 247static bool keyboard_bit_set (SELECT_TYPE *);
252#endif 248#endif
253static void deactivate_process (Lisp_Object); 249static void deactivate_process (Lisp_Object);
254static void status_notify (struct Lisp_Process *); 250static void status_notify (struct Lisp_Process *);
@@ -670,7 +666,7 @@ status_convert (int w)
670 and store them individually through the three pointers. */ 666 and store them individually through the three pointers. */
671 667
672static void 668static void
673decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, int *coredump) 669decode_status (Lisp_Object l, Lisp_Object *symbol, int *code, bool *coredump)
674{ 670{
675 Lisp_Object tem; 671 Lisp_Object tem;
676 672
@@ -697,7 +693,8 @@ status_message (struct Lisp_Process *p)
697{ 693{
698 Lisp_Object status = p->status; 694 Lisp_Object status = p->status;
699 Lisp_Object symbol; 695 Lisp_Object symbol;
700 int code, coredump; 696 int code;
697 bool coredump;
701 Lisp_Object string, string2; 698 Lisp_Object string, string2;
702 699
703 decode_status (status, &symbol, &code, &coredump); 700 decode_status (status, &symbol, &code, &coredump);
@@ -1774,7 +1771,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1774 sigset_t blocked; 1771 sigset_t blocked;
1775 /* Use volatile to protect variables from being clobbered by vfork. */ 1772 /* Use volatile to protect variables from being clobbered by vfork. */
1776 volatile int forkin, forkout; 1773 volatile int forkin, forkout;
1777 volatile int pty_flag = 0; 1774 volatile bool pty_flag = 0;
1778 volatile Lisp_Object lisp_pty_name = Qnil; 1775 volatile Lisp_Object lisp_pty_name = Qnil;
1779 volatile Lisp_Object encoded_current_dir; 1776 volatile Lisp_Object encoded_current_dir;
1780 1777
@@ -2063,7 +2060,7 @@ void
2063create_pty (Lisp_Object process) 2060create_pty (Lisp_Object process)
2064{ 2061{
2065 int inchannel, outchannel; 2062 int inchannel, outchannel;
2066 int pty_flag = 0; 2063 bool pty_flag = 0;
2067 2064
2068 inchannel = outchannel = -1; 2065 inchannel = outchannel = -1;
2069 2066
@@ -3005,8 +3002,9 @@ usage: (make-network-process &rest ARGS) */)
3005 Lisp_Object tem; 3002 Lisp_Object tem;
3006 Lisp_Object name, buffer, host, service, address; 3003 Lisp_Object name, buffer, host, service, address;
3007 Lisp_Object filter, sentinel; 3004 Lisp_Object filter, sentinel;
3008 int is_non_blocking_client = 0; 3005 bool is_non_blocking_client = 0;
3009 int is_server = 0, backlog = 5; 3006 bool is_server = 0;
3007 int backlog = 5;
3010 int socktype; 3008 int socktype;
3011 int family = -1; 3009 int family = -1;
3012 3010
@@ -3676,7 +3674,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3676 struct ifreq *ifreq; 3674 struct ifreq *ifreq;
3677 void *buf = NULL; 3675 void *buf = NULL;
3678 ptrdiff_t buf_size = 512; 3676 ptrdiff_t buf_size = 512;
3679 int s, i; 3677 int s;
3680 Lisp_Object res; 3678 Lisp_Object res;
3681 3679
3682 s = socket (AF_INET, SOCK_STREAM, 0); 3680 s = socket (AF_INET, SOCK_STREAM, 0);
@@ -3714,7 +3712,6 @@ format; see the description of ADDRESS in `make-network-process'. */)
3714 int len = sizeof (*ifreq); 3712 int len = sizeof (*ifreq);
3715#endif 3713#endif
3716 char namebuf[sizeof (ifq->ifr_name) + 1]; 3714 char namebuf[sizeof (ifq->ifr_name) + 1];
3717 i += len;
3718 ifreq = (struct ifreq *) ((char *) ifreq + len); 3715 ifreq = (struct ifreq *) ((char *) ifreq + len);
3719 3716
3720 if (ifq->ifr_addr.sa_family != AF_INET) 3717 if (ifq->ifr_addr.sa_family != AF_INET)
@@ -3824,7 +3821,7 @@ FLAGS is the current flags of the interface. */)
3824 Lisp_Object res = Qnil; 3821 Lisp_Object res = Qnil;
3825 Lisp_Object elt; 3822 Lisp_Object elt;
3826 int s; 3823 int s;
3827 int any = 0; 3824 bool any = 0;
3828#if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \ 3825#if (! (defined SIOCGIFHWADDR && defined HAVE_STRUCT_IFREQ_IFR_HWADDR) \
3829 && defined HAVE_GETIFADDRS && defined LLADDR) 3826 && defined HAVE_GETIFADDRS && defined LLADDR)
3830 struct ifaddrs *ifap; 3827 struct ifaddrs *ifap;
@@ -4114,7 +4111,7 @@ Return non-nil if we received any output before the timeout expired. */)
4114 4111
4115/* Accept a connection for server process SERVER on CHANNEL. */ 4112/* Accept a connection for server process SERVER on CHANNEL. */
4116 4113
4117static int connect_counter = 0; 4114static EMACS_INT connect_counter = 0;
4118 4115
4119static void 4116static void
4120server_accept_connection (Lisp_Object server, int channel) 4117server_accept_connection (Lisp_Object server, int channel)
@@ -4353,7 +4350,7 @@ wait_reading_process_output_1 (void)
4353 process. The return value is true if we read some input from 4350 process. The return value is true if we read some input from
4354 that process. 4351 that process.
4355 4352
4356 If JUST_WAIT_PROC is non-nil, handle only output from WAIT_PROC 4353 If JUST_WAIT_PROC is nonzero, handle only output from WAIT_PROC
4357 (suspending output from other processes). A negative value 4354 (suspending output from other processes). A negative value
4358 means don't run any timers either. 4355 means don't run any timers either.
4359 4356
@@ -4361,22 +4358,23 @@ wait_reading_process_output_1 (void)
4361 received input from that process before the timeout elapsed. 4358 received input from that process before the timeout elapsed.
4362 Otherwise, return true if we received input from any process. */ 4359 Otherwise, return true if we received input from any process. */
4363 4360
4364int 4361bool
4365wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 4362wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4366 bool do_display, 4363 bool do_display,
4367 Lisp_Object wait_for_cell, 4364 Lisp_Object wait_for_cell,
4368 struct Lisp_Process *wait_proc, int just_wait_proc) 4365 struct Lisp_Process *wait_proc, int just_wait_proc)
4369{ 4366{
4370 register int channel, nfds; 4367 int channel, nfds;
4371 SELECT_TYPE Available; 4368 SELECT_TYPE Available;
4372 SELECT_TYPE Writeok; 4369 SELECT_TYPE Writeok;
4373 int check_write; 4370 bool check_write;
4374 int check_delay, no_avail; 4371 int check_delay;
4372 bool no_avail;
4375 int xerrno; 4373 int xerrno;
4376 Lisp_Object proc; 4374 Lisp_Object proc;
4377 EMACS_TIME timeout, end_time; 4375 EMACS_TIME timeout, end_time;
4378 int wait_channel = -1; 4376 int wait_channel = -1;
4379 int got_some_input = 0; 4377 bool got_some_input = 0;
4380 ptrdiff_t count = SPECPDL_INDEX (); 4378 ptrdiff_t count = SPECPDL_INDEX ();
4381 4379
4382 eassert (wait_proc == NULL 4380 eassert (wait_proc == NULL
@@ -4389,7 +4387,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4389 if (time_limit == 0 && nsecs == 0 && wait_proc && !NILP (Vinhibit_quit) 4387 if (time_limit == 0 && nsecs == 0 && wait_proc && !NILP (Vinhibit_quit)
4390 && !(CONSP (wait_proc->status) 4388 && !(CONSP (wait_proc->status)
4391 && EQ (XCAR (wait_proc->status), Qexit))) 4389 && EQ (XCAR (wait_proc->status), Qexit)))
4392 message ("Blocking call to accept-process-output with quit inhibited!!"); 4390 message1 ("Blocking call to accept-process-output with quit inhibited!!");
4393 4391
4394 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4392 /* If wait_proc is a process to watch, set wait_channel accordingly. */
4395 if (wait_proc != NULL) 4393 if (wait_proc != NULL)
@@ -4417,7 +4415,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4417 4415
4418 while (1) 4416 while (1)
4419 { 4417 {
4420 int timeout_reduced_for_timers = 0; 4418 bool timeout_reduced_for_timers = 0;
4421 4419
4422 /* If calling from keyboard input, do not quit 4420 /* If calling from keyboard input, do not quit
4423 since we want to return C-g as an input character. 4421 since we want to return C-g as an input character.
@@ -4796,7 +4794,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4796 unsigned old_timers_run = timers_run; 4794 unsigned old_timers_run = timers_run;
4797 struct buffer *old_buffer = current_buffer; 4795 struct buffer *old_buffer = current_buffer;
4798 Lisp_Object old_window = selected_window; 4796 Lisp_Object old_window = selected_window;
4799 int leave = 0; 4797 bool leave = 0;
4800 4798
4801 if (detect_input_pending_run_timers (do_display)) 4799 if (detect_input_pending_run_timers (do_display))
4802 { 4800 {
@@ -5111,7 +5109,7 @@ read_process_output (Lisp_Object proc, register int channel)
5111 else 5109 else
5112#endif 5110#endif
5113 { 5111 {
5114 int buffered = 0 <= proc_buffered_char[channel]; 5112 bool buffered = 0 <= proc_buffered_char[channel];
5115 if (buffered) 5113 if (buffered)
5116 { 5114 {
5117 chars[carryover] = proc_buffered_char[channel]; 5115 chars[carryover] = proc_buffered_char[channel];
@@ -5427,7 +5425,7 @@ read_process_output (Lisp_Object proc, register int channel)
5427 5425
5428static void 5426static void
5429write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj, 5427write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj,
5430 const char *buf, ptrdiff_t len, int front) 5428 const char *buf, ptrdiff_t len, bool front)
5431{ 5429{
5432 ptrdiff_t offset; 5430 ptrdiff_t offset;
5433 Lisp_Object entry, obj; 5431 Lisp_Object entry, obj;
@@ -5452,10 +5450,10 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj,
5452} 5450}
5453 5451
5454/* Remove the first element in the write_queue of process P, put its 5452/* Remove the first element in the write_queue of process P, put its
5455 contents in OBJ, BUF and LEN, and return non-zero. If the 5453 contents in OBJ, BUF and LEN, and return true. If the
5456 write_queue is empty, return zero. */ 5454 write_queue is empty, return false. */
5457 5455
5458static int 5456static bool
5459write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj, 5457write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj,
5460 const char **buf, ptrdiff_t *len) 5458 const char **buf, ptrdiff_t *len)
5461{ 5459{
@@ -5729,7 +5727,7 @@ Output from processes can arrive in between bunches. */)
5729 if (XINT (start) < GPT && XINT (end) > GPT) 5727 if (XINT (start) < GPT && XINT (end) > GPT)
5730 move_gap_both (XINT (start), start_byte); 5728 move_gap_both (XINT (start), start_byte);
5731 5729
5732 send_process (proc, (char *) BYTE_POS_ADDR (start_byte), 5730 send_process (proc, (char *) BYTE_POS_ADDR (start_byte),
5733 end_byte - start_byte, Fcurrent_buffer ()); 5731 end_byte - start_byte, Fcurrent_buffer ());
5734 5732
5735 return Qnil; 5733 return Qnil;
@@ -5816,7 +5814,7 @@ return t unconditionally. */)
5816 If CURRENT_GROUP is lambda, that means send to the process group 5814 If CURRENT_GROUP is lambda, that means send to the process group
5817 that currently owns the terminal, but only if it is NOT the shell itself. 5815 that currently owns the terminal, but only if it is NOT the shell itself.
5818 5816
5819 If NOMSG is zero, insert signal-announcements into process's buffers 5817 If NOMSG is false, insert signal-announcements into process's buffers
5820 right away. 5818 right away.
5821 5819
5822 If we can, we try to signal PROCESS by sending control characters 5820 If we can, we try to signal PROCESS by sending control characters
@@ -5825,12 +5823,12 @@ return t unconditionally. */)
5825 5823
5826static void 5824static void
5827process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, 5825process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
5828 int nomsg) 5826 bool nomsg)
5829{ 5827{
5830 Lisp_Object proc; 5828 Lisp_Object proc;
5831 register struct Lisp_Process *p; 5829 struct Lisp_Process *p;
5832 pid_t gid; 5830 pid_t gid;
5833 int no_pgrp = 0; 5831 bool no_pgrp = 0;
5834 5832
5835 proc = get_process (process); 5833 proc = get_process (process);
5836 p = XPROCESS (proc); 5834 p = XPROCESS (proc);
@@ -6323,7 +6321,7 @@ handle_child_signal (int sig)
6323 /* If process has terminated, stop waiting for its output. */ 6321 /* If process has terminated, stop waiting for its output. */
6324 if (WIFSIGNALED (status) || WIFEXITED (status)) 6322 if (WIFSIGNALED (status) || WIFEXITED (status))
6325 { 6323 {
6326 int clear_desc_flag = 0; 6324 bool clear_desc_flag = 0;
6327 p->alive = 0; 6325 p->alive = 0;
6328 if (p->infd >= 0) 6326 if (p->infd >= 0)
6329 clear_desc_flag = 1; 6327 clear_desc_flag = 1;
@@ -6663,10 +6661,10 @@ delete_gpm_wait_descriptor (int desc)
6663 6661
6664# ifdef USABLE_SIGIO 6662# ifdef USABLE_SIGIO
6665 6663
6666/* Return nonzero if *MASK has a bit set 6664/* Return true if *MASK has a bit set
6667 that corresponds to one of the keyboard input descriptors. */ 6665 that corresponds to one of the keyboard input descriptors. */
6668 6666
6669static int 6667static bool
6670keyboard_bit_set (fd_set *mask) 6668keyboard_bit_set (fd_set *mask)
6671{ 6669{
6672 int fd; 6670 int fd;
@@ -6716,7 +6714,7 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
6716 6714
6717 Return true if we received input from any process. */ 6715 Return true if we received input from any process. */
6718 6716
6719int 6717bool
6720wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, 6718wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6721 bool do_display, 6719 bool do_display,
6722 Lisp_Object wait_for_cell, 6720 Lisp_Object wait_for_cell,
@@ -6748,7 +6746,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
6748 6746
6749 while (1) 6747 while (1)
6750 { 6748 {
6751 int timeout_reduced_for_timers = 0; 6749 bool timeout_reduced_for_timers = 0;
6752 SELECT_TYPE waitchannels; 6750 SELECT_TYPE waitchannels;
6753 int xerrno; 6751 int xerrno;
6754 6752
@@ -7105,9 +7103,9 @@ unhold_keyboard_input (void)
7105 kbd_is_on_hold = 0; 7103 kbd_is_on_hold = 0;
7106} 7104}
7107 7105
7108/* Return non-zero if keyboard input is on hold, zero otherwise. */ 7106/* Return true if keyboard input is on hold, zero otherwise. */
7109 7107
7110int 7108bool
7111kbd_on_hold_p (void) 7109kbd_on_hold_p (void)
7112{ 7110{
7113 return kbd_is_on_hold; 7111 return kbd_is_on_hold;