diff options
| author | Kenichi Handa | 2012-07-17 07:09:08 +0900 |
|---|---|---|
| committer | Kenichi Handa | 2012-07-17 07:09:08 +0900 |
| commit | 8c536f15bf95916d56bb50495d22b7da7e09fff9 (patch) | |
| tree | ac6f8bf5103bdbd1d6a75f05def9bc7aa9e96547 /src/process.c | |
| parent | 21a8caaa4af24f258e6c7f80c1fc913b00aee044 (diff) | |
| parent | c05cf3902ae658cc8bf413124245c9e1cdcca2d7 (diff) | |
| download | emacs-8c536f15bf95916d56bb50495d22b7da7e09fff9.tar.gz emacs-8c536f15bf95916d56bb50495d22b7da7e09fff9.zip | |
merge trunk
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 162 |
1 files changed, 70 insertions, 92 deletions
diff --git a/src/process.c b/src/process.c index cf6d40052a7..4d59ff0d452 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -182,9 +182,9 @@ extern int h_errno; | |||
| 182 | #endif | 182 | #endif |
| 183 | 183 | ||
| 184 | /* Number of events of change of status of a process. */ | 184 | /* Number of events of change of status of a process. */ |
| 185 | static int process_tick; | 185 | static EMACS_INT process_tick; |
| 186 | /* Number of events for which the user or sentinel has been notified. */ | 186 | /* Number of events for which the user or sentinel has been notified. */ |
| 187 | static int update_tick; | 187 | static EMACS_INT update_tick; |
| 188 | 188 | ||
| 189 | /* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ | 189 | /* Define NON_BLOCKING_CONNECT if we can support non-blocking connects. */ |
| 190 | 190 | ||
| @@ -774,9 +774,7 @@ nil, indicating the current buffer's process. */) | |||
| 774 | { | 774 | { |
| 775 | #ifdef SIGCHLD | 775 | #ifdef SIGCHLD |
| 776 | Lisp_Object symbol; | 776 | Lisp_Object symbol; |
| 777 | /* Assignment to EMACS_INT stops GCC whining about limited range | 777 | pid_t pid = p->pid; |
| 778 | of data type. */ | ||
| 779 | EMACS_INT pid = p->pid; | ||
| 780 | 778 | ||
| 781 | /* No problem storing the pid here, as it is still in Vprocess_alist. */ | 779 | /* No problem storing the pid here, as it is still in Vprocess_alist. */ |
| 782 | deleted_pid_list = Fcons (make_fixnum_or_float (pid), | 780 | deleted_pid_list = Fcons (make_fixnum_or_float (pid), |
| @@ -873,9 +871,7 @@ This is the pid of the external process which PROCESS uses or talks to. | |||
| 873 | For a network connection, this value is nil. */) | 871 | For a network connection, this value is nil. */) |
| 874 | (register Lisp_Object process) | 872 | (register Lisp_Object process) |
| 875 | { | 873 | { |
| 876 | /* Assignment to EMACS_INT stops GCC whining about limited range of | 874 | pid_t pid; |
| 877 | data type. */ | ||
| 878 | EMACS_INT pid; | ||
| 879 | 875 | ||
| 880 | CHECK_PROCESS (process); | 876 | CHECK_PROCESS (process); |
| 881 | pid = XPROCESS (process)->pid; | 877 | pid = XPROCESS (process)->pid; |
| @@ -1050,8 +1046,8 @@ DEFUN ("set-process-window-size", Fset_process_window_size, | |||
| 1050 | (register Lisp_Object process, Lisp_Object height, Lisp_Object width) | 1046 | (register Lisp_Object process, Lisp_Object height, Lisp_Object width) |
| 1051 | { | 1047 | { |
| 1052 | CHECK_PROCESS (process); | 1048 | CHECK_PROCESS (process); |
| 1053 | CHECK_NATNUM (height); | 1049 | CHECK_RANGED_INTEGER (0, height, INT_MAX); |
| 1054 | CHECK_NATNUM (width); | 1050 | CHECK_RANGED_INTEGER (0, width, INT_MAX); |
| 1055 | 1051 | ||
| 1056 | if (XPROCESS (process)->infd < 0 | 1052 | if (XPROCESS (process)->infd < 0 |
| 1057 | || set_window_size (XPROCESS (process)->infd, | 1053 | || set_window_size (XPROCESS (process)->infd, |
| @@ -1214,7 +1210,7 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1214 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ | 1210 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ |
| 1215 | { | 1211 | { |
| 1216 | register struct Lisp_Vector *p = XVECTOR (address); | 1212 | register struct Lisp_Vector *p = XVECTOR (address); |
| 1217 | EMACS_INT size = p->header.size; | 1213 | ptrdiff_t size = p->header.size; |
| 1218 | Lisp_Object args[10]; | 1214 | Lisp_Object args[10]; |
| 1219 | int nargs, i; | 1215 | int nargs, i; |
| 1220 | 1216 | ||
| @@ -1243,14 +1239,12 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1243 | 1239 | ||
| 1244 | for (i = 0; i < nargs; i++) | 1240 | for (i = 0; i < nargs; i++) |
| 1245 | { | 1241 | { |
| 1246 | EMACS_INT element = XINT (p->contents[i]); | 1242 | if (! RANGED_INTEGERP (0, p->contents[i], 65535)) |
| 1247 | |||
| 1248 | if (element < 0 || element > 65535) | ||
| 1249 | return Qnil; | 1243 | return Qnil; |
| 1250 | 1244 | ||
| 1251 | if (nargs <= 5 /* IPv4 */ | 1245 | if (nargs <= 5 /* IPv4 */ |
| 1252 | && i < 4 /* host, not port */ | 1246 | && i < 4 /* host, not port */ |
| 1253 | && element > 255) | 1247 | && XINT (p->contents[i]) > 255) |
| 1254 | return Qnil; | 1248 | return Qnil; |
| 1255 | 1249 | ||
| 1256 | args[i+1] = p->contents[i]; | 1250 | args[i+1] = p->contents[i]; |
| @@ -1305,7 +1299,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */) | |||
| 1305 | Lisp_Object buffer, name, program, proc, current_dir, tem; | 1299 | Lisp_Object buffer, name, program, proc, current_dir, tem; |
| 1306 | register unsigned char **new_argv; | 1300 | register unsigned char **new_argv; |
| 1307 | ptrdiff_t i; | 1301 | ptrdiff_t i; |
| 1308 | int count = SPECPDL_INDEX (); | 1302 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1309 | 1303 | ||
| 1310 | buffer = args[1]; | 1304 | buffer = args[1]; |
| 1311 | if (!NILP (buffer)) | 1305 | if (!NILP (buffer)) |
| @@ -2115,7 +2109,8 @@ get_lisp_to_sockaddr_size (Lisp_Object address, int *familyp) | |||
| 2115 | return sizeof (struct sockaddr_un); | 2109 | return sizeof (struct sockaddr_un); |
| 2116 | } | 2110 | } |
| 2117 | #endif | 2111 | #endif |
| 2118 | else if (CONSP (address) && INTEGERP (XCAR (address)) && VECTORP (XCDR (address))) | 2112 | else if (CONSP (address) && TYPE_RANGED_INTEGERP (int, XCAR (address)) |
| 2113 | && VECTORP (XCDR (address))) | ||
| 2119 | { | 2114 | { |
| 2120 | struct sockaddr *sa; | 2115 | struct sockaddr *sa; |
| 2121 | *familyp = XINT (XCAR (address)); | 2116 | *familyp = XINT (XCAR (address)); |
| @@ -2138,6 +2133,7 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int | |||
| 2138 | register struct Lisp_Vector *p; | 2133 | register struct Lisp_Vector *p; |
| 2139 | register unsigned char *cp = NULL; | 2134 | register unsigned char *cp = NULL; |
| 2140 | register int i; | 2135 | register int i; |
| 2136 | EMACS_INT hostport; | ||
| 2141 | 2137 | ||
| 2142 | memset (sa, 0, len); | 2138 | memset (sa, 0, len); |
| 2143 | 2139 | ||
| @@ -2148,8 +2144,8 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int | |||
| 2148 | { | 2144 | { |
| 2149 | struct sockaddr_in *sin = (struct sockaddr_in *) sa; | 2145 | struct sockaddr_in *sin = (struct sockaddr_in *) sa; |
| 2150 | len = sizeof (sin->sin_addr) + 1; | 2146 | len = sizeof (sin->sin_addr) + 1; |
| 2151 | i = XINT (p->contents[--len]); | 2147 | hostport = XINT (p->contents[--len]); |
| 2152 | sin->sin_port = htons (i); | 2148 | sin->sin_port = htons (hostport); |
| 2153 | cp = (unsigned char *)&sin->sin_addr; | 2149 | cp = (unsigned char *)&sin->sin_addr; |
| 2154 | sa->sa_family = family; | 2150 | sa->sa_family = family; |
| 2155 | } | 2151 | } |
| @@ -2159,8 +2155,8 @@ conv_lisp_to_sockaddr (int family, Lisp_Object address, struct sockaddr *sa, int | |||
| 2159 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; | 2155 | struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) sa; |
| 2160 | uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr; | 2156 | uint16_t *ip6 = (uint16_t *)&sin6->sin6_addr; |
| 2161 | len = sizeof (sin6->sin6_addr) + 1; | 2157 | len = sizeof (sin6->sin6_addr) + 1; |
| 2162 | i = XINT (p->contents[--len]); | 2158 | hostport = XINT (p->contents[--len]); |
| 2163 | sin6->sin6_port = htons (i); | 2159 | sin6->sin6_port = htons (hostport); |
| 2164 | for (i = 0; i < len; i++) | 2160 | for (i = 0; i < len; i++) |
| 2165 | if (INTEGERP (p->contents[i])) | 2161 | if (INTEGERP (p->contents[i])) |
| 2166 | { | 2162 | { |
| @@ -2315,7 +2311,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val) | |||
| 2315 | case SOPT_INT: | 2311 | case SOPT_INT: |
| 2316 | { | 2312 | { |
| 2317 | int optval; | 2313 | int optval; |
| 2318 | if (INTEGERP (val)) | 2314 | if (TYPE_RANGED_INTEGERP (int, val)) |
| 2319 | optval = XINT (val); | 2315 | optval = XINT (val); |
| 2320 | else | 2316 | else |
| 2321 | error ("Bad option value for %s", name); | 2317 | error ("Bad option value for %s", name); |
| @@ -2354,7 +2350,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val) | |||
| 2354 | 2350 | ||
| 2355 | linger.l_onoff = 1; | 2351 | linger.l_onoff = 1; |
| 2356 | linger.l_linger = 0; | 2352 | linger.l_linger = 0; |
| 2357 | if (INTEGERP (val)) | 2353 | if (TYPE_RANGED_INTEGERP (int, val)) |
| 2358 | linger.l_linger = XINT (val); | 2354 | linger.l_linger = XINT (val); |
| 2359 | else | 2355 | else |
| 2360 | linger.l_onoff = NILP (val) ? 0 : 1; | 2356 | linger.l_onoff = NILP (val) ? 0 : 1; |
| @@ -2593,7 +2589,7 @@ usage: (make-serial-process &rest ARGS) */) | |||
| 2593 | struct gcpro gcpro1; | 2589 | struct gcpro gcpro1; |
| 2594 | Lisp_Object name, buffer; | 2590 | Lisp_Object name, buffer; |
| 2595 | Lisp_Object tem, val; | 2591 | Lisp_Object tem, val; |
| 2596 | int specpdl_count = -1; | 2592 | ptrdiff_t specpdl_count = -1; |
| 2597 | 2593 | ||
| 2598 | if (nargs == 0) | 2594 | if (nargs == 0) |
| 2599 | return Qnil; | 2595 | return Qnil; |
| @@ -2893,8 +2889,8 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2893 | int xerrno = 0; | 2889 | int xerrno = 0; |
| 2894 | int s = -1, outch, inch; | 2890 | int s = -1, outch, inch; |
| 2895 | struct gcpro gcpro1; | 2891 | struct gcpro gcpro1; |
| 2896 | int count = SPECPDL_INDEX (); | 2892 | ptrdiff_t count = SPECPDL_INDEX (); |
| 2897 | int count1; | 2893 | ptrdiff_t count1; |
| 2898 | Lisp_Object QCaddress; /* one of QClocal or QCremote */ | 2894 | Lisp_Object QCaddress; /* one of QClocal or QCremote */ |
| 2899 | Lisp_Object tem; | 2895 | Lisp_Object tem; |
| 2900 | Lisp_Object name, buffer, host, service, address; | 2896 | Lisp_Object name, buffer, host, service, address; |
| @@ -2941,7 +2937,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2941 | error ("Network servers not supported"); | 2937 | error ("Network servers not supported"); |
| 2942 | #else | 2938 | #else |
| 2943 | is_server = 1; | 2939 | is_server = 1; |
| 2944 | if (INTEGERP (tem)) | 2940 | if (TYPE_RANGED_INTEGERP (int, tem)) |
| 2945 | backlog = XINT (tem); | 2941 | backlog = XINT (tem); |
| 2946 | #endif | 2942 | #endif |
| 2947 | } | 2943 | } |
| @@ -3007,7 +3003,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3007 | #endif | 3003 | #endif |
| 3008 | else if (EQ (tem, Qipv4)) | 3004 | else if (EQ (tem, Qipv4)) |
| 3009 | family = AF_INET; | 3005 | family = AF_INET; |
| 3010 | else if (INTEGERP (tem)) | 3006 | else if (TYPE_RANGED_INTEGERP (int, tem)) |
| 3011 | family = XINT (tem); | 3007 | family = XINT (tem); |
| 3012 | else | 3008 | else |
| 3013 | error ("Unknown address family"); | 3009 | error ("Unknown address family"); |
| @@ -3964,7 +3960,7 @@ If JUST-THIS-ONE is an integer, don't run any timers either. | |||
| 3964 | Return non-nil if we received any output before the timeout expired. */) | 3960 | Return non-nil if we received any output before the timeout expired. */) |
| 3965 | (register Lisp_Object process, Lisp_Object seconds, Lisp_Object millisec, Lisp_Object just_this_one) | 3961 | (register Lisp_Object process, Lisp_Object seconds, Lisp_Object millisec, Lisp_Object just_this_one) |
| 3966 | { | 3962 | { |
| 3967 | int secs, usecs = 0; | 3963 | int secs = -1, usecs = 0; |
| 3968 | 3964 | ||
| 3969 | if (! NILP (process)) | 3965 | if (! NILP (process)) |
| 3970 | CHECK_PROCESS (process); | 3966 | CHECK_PROCESS (process); |
| @@ -3985,22 +3981,12 @@ Return non-nil if we received any output before the timeout expired. */) | |||
| 3985 | 3981 | ||
| 3986 | if (!NILP (seconds)) | 3982 | if (!NILP (seconds)) |
| 3987 | { | 3983 | { |
| 3988 | if (INTEGERP (seconds)) | 3984 | double duration = extract_float (seconds); |
| 3989 | secs = XINT (seconds); | 3985 | if (0 < duration) |
| 3990 | else if (FLOATP (seconds)) | 3986 | duration_to_sec_usec (duration, &secs, &usecs); |
| 3991 | { | ||
| 3992 | double timeout = XFLOAT_DATA (seconds); | ||
| 3993 | secs = (int) timeout; | ||
| 3994 | usecs = (int) ((timeout - (double) secs) * 1000000); | ||
| 3995 | } | ||
| 3996 | else | ||
| 3997 | wrong_type_argument (Qnumberp, seconds); | ||
| 3998 | |||
| 3999 | if (secs < 0 || (secs == 0 && usecs == 0)) | ||
| 4000 | secs = -1, usecs = 0; | ||
| 4001 | } | 3987 | } |
| 4002 | else | 3988 | else if (!NILP (process)) |
| 4003 | secs = NILP (process) ? -1 : 0; | 3989 | secs = 0; |
| 4004 | 3990 | ||
| 4005 | return | 3991 | return |
| 4006 | (wait_reading_process_output (secs, usecs, 0, 0, | 3992 | (wait_reading_process_output (secs, usecs, 0, 0, |
| @@ -4313,7 +4299,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, | |||
| 4313 | EMACS_TIME timeout, end_time; | 4299 | EMACS_TIME timeout, end_time; |
| 4314 | int wait_channel = -1; | 4300 | int wait_channel = -1; |
| 4315 | int got_some_input = 0; | 4301 | int got_some_input = 0; |
| 4316 | int count = SPECPDL_INDEX (); | 4302 | ptrdiff_t count = SPECPDL_INDEX (); |
| 4317 | 4303 | ||
| 4318 | FD_ZERO (&Available); | 4304 | FD_ZERO (&Available); |
| 4319 | FD_ZERO (&Writeok); | 4305 | FD_ZERO (&Writeok); |
| @@ -5054,11 +5040,11 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5054 | char *chars; | 5040 | char *chars; |
| 5055 | register Lisp_Object outstream; | 5041 | register Lisp_Object outstream; |
| 5056 | register struct Lisp_Process *p = XPROCESS (proc); | 5042 | register struct Lisp_Process *p = XPROCESS (proc); |
| 5057 | register EMACS_INT opoint; | 5043 | register ptrdiff_t opoint; |
| 5058 | struct coding_system *coding = proc_decode_coding_system[channel]; | 5044 | struct coding_system *coding = proc_decode_coding_system[channel]; |
| 5059 | int carryover = p->decoding_carryover; | 5045 | int carryover = p->decoding_carryover; |
| 5060 | int readmax = 4096; | 5046 | int readmax = 4096; |
| 5061 | int count = SPECPDL_INDEX (); | 5047 | ptrdiff_t count = SPECPDL_INDEX (); |
| 5062 | Lisp_Object odeactivate; | 5048 | Lisp_Object odeactivate; |
| 5063 | 5049 | ||
| 5064 | chars = (char *) alloca (carryover + readmax); | 5050 | chars = (char *) alloca (carryover + readmax); |
| @@ -5253,10 +5239,10 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5253 | else if (!NILP (p->buffer) && !NILP (BVAR (XBUFFER (p->buffer), name))) | 5239 | else if (!NILP (p->buffer) && !NILP (BVAR (XBUFFER (p->buffer), name))) |
| 5254 | { | 5240 | { |
| 5255 | Lisp_Object old_read_only; | 5241 | Lisp_Object old_read_only; |
| 5256 | EMACS_INT old_begv, old_zv; | 5242 | ptrdiff_t old_begv, old_zv; |
| 5257 | EMACS_INT old_begv_byte, old_zv_byte; | 5243 | ptrdiff_t old_begv_byte, old_zv_byte; |
| 5258 | EMACS_INT before, before_byte; | 5244 | ptrdiff_t before, before_byte; |
| 5259 | EMACS_INT opoint_byte; | 5245 | ptrdiff_t opoint_byte; |
| 5260 | Lisp_Object text; | 5246 | Lisp_Object text; |
| 5261 | struct buffer *b; | 5247 | struct buffer *b; |
| 5262 | 5248 | ||
| @@ -5397,7 +5383,7 @@ send_process_trap (int ignore) | |||
| 5397 | 5383 | ||
| 5398 | static void | 5384 | static void |
| 5399 | send_process (volatile Lisp_Object proc, const char *volatile buf, | 5385 | send_process (volatile Lisp_Object proc, const char *volatile buf, |
| 5400 | volatile EMACS_INT len, volatile Lisp_Object object) | 5386 | volatile ptrdiff_t len, volatile Lisp_Object object) |
| 5401 | { | 5387 | { |
| 5402 | /* Use volatile to protect variables from being clobbered by longjmp. */ | 5388 | /* Use volatile to protect variables from being clobbered by longjmp. */ |
| 5403 | struct Lisp_Process *p = XPROCESS (proc); | 5389 | struct Lisp_Process *p = XPROCESS (proc); |
| @@ -5468,8 +5454,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5468 | coding->dst_object = Qt; | 5454 | coding->dst_object = Qt; |
| 5469 | if (BUFFERP (object)) | 5455 | if (BUFFERP (object)) |
| 5470 | { | 5456 | { |
| 5471 | EMACS_INT from_byte, from, to; | 5457 | ptrdiff_t from_byte, from, to; |
| 5472 | EMACS_INT save_pt, save_pt_byte; | 5458 | ptrdiff_t save_pt, save_pt_byte; |
| 5473 | struct buffer *cur = current_buffer; | 5459 | struct buffer *cur = current_buffer; |
| 5474 | 5460 | ||
| 5475 | set_buffer_internal (XBUFFER (object)); | 5461 | set_buffer_internal (XBUFFER (object)); |
| @@ -5523,12 +5509,12 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5523 | process_sent_to = proc; | 5509 | process_sent_to = proc; |
| 5524 | while (len > 0) | 5510 | while (len > 0) |
| 5525 | { | 5511 | { |
| 5526 | EMACS_INT this = len; | 5512 | ptrdiff_t this = len; |
| 5527 | 5513 | ||
| 5528 | /* Send this batch, using one or more write calls. */ | 5514 | /* Send this batch, using one or more write calls. */ |
| 5529 | while (this > 0) | 5515 | while (this > 0) |
| 5530 | { | 5516 | { |
| 5531 | EMACS_INT written = 0; | 5517 | ptrdiff_t written = 0; |
| 5532 | int outfd = p->outfd; | 5518 | int outfd = p->outfd; |
| 5533 | old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap); | 5519 | old_sigpipe = (void (*) (int)) signal (SIGPIPE, send_process_trap); |
| 5534 | #ifdef DATAGRAM_SOCKETS | 5520 | #ifdef DATAGRAM_SOCKETS |
| @@ -5582,7 +5568,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf, | |||
| 5582 | that may allow the program | 5568 | that may allow the program |
| 5583 | to finish doing output and read more. */ | 5569 | to finish doing output and read more. */ |
| 5584 | { | 5570 | { |
| 5585 | EMACS_INT offset = 0; | 5571 | ptrdiff_t offset = 0; |
| 5586 | 5572 | ||
| 5587 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN | 5573 | #ifdef BROKEN_PTY_READ_AFTER_EAGAIN |
| 5588 | /* A gross hack to work around a bug in FreeBSD. | 5574 | /* A gross hack to work around a bug in FreeBSD. |
| @@ -5666,7 +5652,7 @@ Output from processes can arrive in between bunches. */) | |||
| 5666 | (Lisp_Object process, Lisp_Object start, Lisp_Object end) | 5652 | (Lisp_Object process, Lisp_Object start, Lisp_Object end) |
| 5667 | { | 5653 | { |
| 5668 | Lisp_Object proc; | 5654 | Lisp_Object proc; |
| 5669 | EMACS_INT start1, end1; | 5655 | ptrdiff_t start1, end1; |
| 5670 | 5656 | ||
| 5671 | proc = get_process (process); | 5657 | proc = get_process (process); |
| 5672 | validate_region (&start, &end); | 5658 | validate_region (&start, &end); |
| @@ -5702,10 +5688,10 @@ Output from processes can arrive in between bunches. */) | |||
| 5702 | 5688 | ||
| 5703 | /* Return the foreground process group for the tty/pty that | 5689 | /* Return the foreground process group for the tty/pty that |
| 5704 | the process P uses. */ | 5690 | the process P uses. */ |
| 5705 | static int | 5691 | static pid_t |
| 5706 | emacs_get_tty_pgrp (struct Lisp_Process *p) | 5692 | emacs_get_tty_pgrp (struct Lisp_Process *p) |
| 5707 | { | 5693 | { |
| 5708 | int gid = -1; | 5694 | pid_t gid = -1; |
| 5709 | 5695 | ||
| 5710 | #ifdef TIOCGPGRP | 5696 | #ifdef TIOCGPGRP |
| 5711 | if (ioctl (p->infd, TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) | 5697 | if (ioctl (p->infd, TIOCGPGRP, &gid) == -1 && ! NILP (p->tty_name)) |
| @@ -5735,7 +5721,7 @@ return t unconditionally. */) | |||
| 5735 | { | 5721 | { |
| 5736 | /* Initialize in case ioctl doesn't exist or gives an error, | 5722 | /* Initialize in case ioctl doesn't exist or gives an error, |
| 5737 | in a way that will cause returning t. */ | 5723 | in a way that will cause returning t. */ |
| 5738 | int gid; | 5724 | pid_t gid; |
| 5739 | Lisp_Object proc; | 5725 | Lisp_Object proc; |
| 5740 | struct Lisp_Process *p; | 5726 | struct Lisp_Process *p; |
| 5741 | 5727 | ||
| @@ -5776,7 +5762,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, | |||
| 5776 | { | 5762 | { |
| 5777 | Lisp_Object proc; | 5763 | Lisp_Object proc; |
| 5778 | register struct Lisp_Process *p; | 5764 | register struct Lisp_Process *p; |
| 5779 | int gid; | 5765 | pid_t gid; |
| 5780 | int no_pgrp = 0; | 5766 | int no_pgrp = 0; |
| 5781 | 5767 | ||
| 5782 | proc = get_process (process); | 5768 | proc = get_process (process); |
| @@ -6030,48 +6016,40 @@ SIGCODE may be an integer, or a symbol whose name is a signal name. */) | |||
| 6030 | { | 6016 | { |
| 6031 | pid_t pid; | 6017 | pid_t pid; |
| 6032 | 6018 | ||
| 6033 | if (INTEGERP (process)) | ||
| 6034 | { | ||
| 6035 | pid = XINT (process); | ||
| 6036 | goto got_it; | ||
| 6037 | } | ||
| 6038 | |||
| 6039 | if (FLOATP (process)) | ||
| 6040 | { | ||
| 6041 | pid = (pid_t) XFLOAT_DATA (process); | ||
| 6042 | goto got_it; | ||
| 6043 | } | ||
| 6044 | |||
| 6045 | if (STRINGP (process)) | 6019 | if (STRINGP (process)) |
| 6046 | { | 6020 | { |
| 6047 | Lisp_Object tem; | 6021 | Lisp_Object tem = Fget_process (process); |
| 6048 | if (tem = Fget_process (process), NILP (tem)) | 6022 | if (NILP (tem)) |
| 6049 | { | 6023 | { |
| 6050 | pid = XINT (Fstring_to_number (process, make_number (10))); | 6024 | Lisp_Object process_number = |
| 6051 | if (pid > 0) | 6025 | string_to_number (SSDATA (process), 10, 1); |
| 6052 | goto got_it; | 6026 | if (INTEGERP (process_number) || FLOATP (process_number)) |
| 6027 | tem = process_number; | ||
| 6053 | } | 6028 | } |
| 6054 | process = tem; | 6029 | process = tem; |
| 6055 | } | 6030 | } |
| 6056 | else | 6031 | else if (!NUMBERP (process)) |
| 6057 | process = get_process (process); | 6032 | process = get_process (process); |
| 6058 | 6033 | ||
| 6059 | if (NILP (process)) | 6034 | if (NILP (process)) |
| 6060 | return process; | 6035 | return process; |
| 6061 | 6036 | ||
| 6062 | CHECK_PROCESS (process); | 6037 | if (NUMBERP (process)) |
| 6063 | pid = XPROCESS (process)->pid; | 6038 | CONS_TO_INTEGER (process, pid_t, pid); |
| 6064 | if (pid <= 0) | 6039 | else |
| 6065 | error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); | 6040 | { |
| 6066 | 6041 | CHECK_PROCESS (process); | |
| 6067 | got_it: | 6042 | pid = XPROCESS (process)->pid; |
| 6043 | if (pid <= 0) | ||
| 6044 | error ("Cannot signal process %s", SDATA (XPROCESS (process)->name)); | ||
| 6045 | } | ||
| 6068 | 6046 | ||
| 6069 | #define parse_signal(NAME, VALUE) \ | 6047 | #define parse_signal(NAME, VALUE) \ |
| 6070 | else if (!xstrcasecmp (name, NAME)) \ | 6048 | else if (!xstrcasecmp (name, NAME)) \ |
| 6071 | XSETINT (sigcode, VALUE) | 6049 | XSETINT (sigcode, VALUE) |
| 6072 | 6050 | ||
| 6073 | if (INTEGERP (sigcode)) | 6051 | if (INTEGERP (sigcode)) |
| 6074 | ; | 6052 | CHECK_TYPE_RANGED_INTEGER (int, sigcode); |
| 6075 | else | 6053 | else |
| 6076 | { | 6054 | { |
| 6077 | char *name; | 6055 | char *name; |
| @@ -6334,8 +6312,8 @@ sigchld_handler (int signo) | |||
| 6334 | for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) | 6312 | for (tail = deleted_pid_list; CONSP (tail); tail = XCDR (tail)) |
| 6335 | { | 6313 | { |
| 6336 | Lisp_Object xpid = XCAR (tail); | 6314 | Lisp_Object xpid = XCAR (tail); |
| 6337 | if ((INTEGERP (xpid) && pid == (pid_t) XINT (xpid)) | 6315 | if ((INTEGERP (xpid) && pid == XINT (xpid)) |
| 6338 | || (FLOATP (xpid) && pid == (pid_t) XFLOAT_DATA (xpid))) | 6316 | || (FLOATP (xpid) && pid == XFLOAT_DATA (xpid))) |
| 6339 | { | 6317 | { |
| 6340 | XSETCAR (tail, Qnil); | 6318 | XSETCAR (tail, Qnil); |
| 6341 | goto sigchld_end_of_loop; | 6319 | goto sigchld_end_of_loop; |
| @@ -6451,7 +6429,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason) | |||
| 6451 | { | 6429 | { |
| 6452 | Lisp_Object sentinel, odeactivate; | 6430 | Lisp_Object sentinel, odeactivate; |
| 6453 | register struct Lisp_Process *p = XPROCESS (proc); | 6431 | register struct Lisp_Process *p = XPROCESS (proc); |
| 6454 | int count = SPECPDL_INDEX (); | 6432 | ptrdiff_t count = SPECPDL_INDEX (); |
| 6455 | int outer_running_asynch_code = running_asynch_code; | 6433 | int outer_running_asynch_code = running_asynch_code; |
| 6456 | int waiting = waiting_for_user_input_p; | 6434 | int waiting = waiting_for_user_input_p; |
| 6457 | 6435 | ||
| @@ -6610,8 +6588,8 @@ status_notify (struct Lisp_Process *deleting_process) | |||
| 6610 | { | 6588 | { |
| 6611 | Lisp_Object tem; | 6589 | Lisp_Object tem; |
| 6612 | struct buffer *old = current_buffer; | 6590 | struct buffer *old = current_buffer; |
| 6613 | EMACS_INT opoint, opoint_byte; | 6591 | ptrdiff_t opoint, opoint_byte; |
| 6614 | EMACS_INT before, before_byte; | 6592 | ptrdiff_t before, before_byte; |
| 6615 | 6593 | ||
| 6616 | /* Avoid error if buffer is deleted | 6594 | /* Avoid error if buffer is deleted |
| 6617 | (probably that's why the process is dead, too) */ | 6595 | (probably that's why the process is dead, too) */ |