diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 75 |
1 files changed, 34 insertions, 41 deletions
diff --git a/src/process.c b/src/process.c index c9b420ab2ae..4a7202388bf 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -159,9 +159,6 @@ extern Lisp_Object QCfilter; | |||
| 159 | #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) | 159 | #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) |
| 160 | #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) | 160 | #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) |
| 161 | 161 | ||
| 162 | /* Define first descriptor number available for subprocesses. */ | ||
| 163 | #define FIRST_PROC_DESC 3 | ||
| 164 | |||
| 165 | #ifndef HAVE_H_ERRNO | 162 | #ifndef HAVE_H_ERRNO |
| 166 | extern int h_errno; | 163 | extern int h_errno; |
| 167 | #endif | 164 | #endif |
| @@ -278,10 +275,6 @@ static SELECT_TYPE connect_wait_mask; | |||
| 278 | 275 | ||
| 279 | /* Number of bits set in connect_wait_mask. */ | 276 | /* Number of bits set in connect_wait_mask. */ |
| 280 | static int num_pending_connects; | 277 | static int num_pending_connects; |
| 281 | |||
| 282 | #define IF_NON_BLOCKING_CONNECT(s) s | ||
| 283 | #else /* NON_BLOCKING_CONNECT */ | ||
| 284 | #define IF_NON_BLOCKING_CONNECT(s) | ||
| 285 | #endif /* NON_BLOCKING_CONNECT */ | 278 | #endif /* NON_BLOCKING_CONNECT */ |
| 286 | 279 | ||
| 287 | /* The largest descriptor currently in use for a process object. */ | 280 | /* The largest descriptor currently in use for a process object. */ |
| @@ -1250,8 +1243,8 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1250 | static Lisp_Object | 1243 | static Lisp_Object |
| 1251 | list_processes_1 (Lisp_Object query_only) | 1244 | list_processes_1 (Lisp_Object query_only) |
| 1252 | { | 1245 | { |
| 1253 | register Lisp_Object tail, tem; | 1246 | register Lisp_Object tail; |
| 1254 | Lisp_Object proc, minspace, tem1; | 1247 | Lisp_Object proc, minspace; |
| 1255 | register struct Lisp_Process *p; | 1248 | register struct Lisp_Process *p; |
| 1256 | char tembuf[300]; | 1249 | char tembuf[300]; |
| 1257 | int w_proc, w_buffer, w_tty; | 1250 | int w_proc, w_buffer, w_tty; |
| @@ -1453,10 +1446,10 @@ list_processes_1 (Lisp_Object query_only) | |||
| 1453 | } | 1446 | } |
| 1454 | else | 1447 | else |
| 1455 | { | 1448 | { |
| 1456 | tem = p->command; | 1449 | Lisp_Object tem = p->command; |
| 1457 | while (1) | 1450 | while (1) |
| 1458 | { | 1451 | { |
| 1459 | tem1 = Fcar (tem); | 1452 | Lisp_Object tem1 = Fcar (tem); |
| 1460 | if (NILP (tem1)) | 1453 | if (NILP (tem1)) |
| 1461 | break; | 1454 | break; |
| 1462 | Finsert (1, &tem1); | 1455 | Finsert (1, &tem1); |
| @@ -1919,8 +1912,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1919 | /* child_setup must clobber environ on systems with true vfork. | 1912 | /* child_setup must clobber environ on systems with true vfork. |
| 1920 | Protect it from permanent change. */ | 1913 | Protect it from permanent change. */ |
| 1921 | char **save_environ = environ; | 1914 | char **save_environ = environ; |
| 1922 | 1915 | volatile Lisp_Object encoded_current_dir = ENCODE_FILE (current_dir); | |
| 1923 | current_dir = ENCODE_FILE (current_dir); | ||
| 1924 | 1916 | ||
| 1925 | #ifndef WINDOWSNT | 1917 | #ifndef WINDOWSNT |
| 1926 | pid = vfork (); | 1918 | pid = vfork (); |
| @@ -2061,13 +2053,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 2061 | child_setup_tty (xforkout); | 2053 | child_setup_tty (xforkout); |
| 2062 | #ifdef WINDOWSNT | 2054 | #ifdef WINDOWSNT |
| 2063 | pid = child_setup (xforkin, xforkout, xforkout, | 2055 | pid = child_setup (xforkin, xforkout, xforkout, |
| 2064 | new_argv, 1, current_dir); | 2056 | new_argv, 1, encoded_current_dir); |
| 2065 | #else /* not WINDOWSNT */ | 2057 | #else /* not WINDOWSNT */ |
| 2066 | #ifdef FD_CLOEXEC | 2058 | #ifdef FD_CLOEXEC |
| 2067 | emacs_close (wait_child_setup[0]); | 2059 | emacs_close (wait_child_setup[0]); |
| 2068 | #endif | 2060 | #endif |
| 2069 | child_setup (xforkin, xforkout, xforkout, | 2061 | child_setup (xforkin, xforkout, xforkout, |
| 2070 | new_argv, 1, current_dir); | 2062 | new_argv, 1, encoded_current_dir); |
| 2071 | #endif /* not WINDOWSNT */ | 2063 | #endif /* not WINDOWSNT */ |
| 2072 | } | 2064 | } |
| 2073 | environ = save_environ; | 2065 | environ = save_environ; |
| @@ -3403,7 +3395,9 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3403 | { | 3395 | { |
| 3404 | int optn, optbits; | 3396 | int optn, optbits; |
| 3405 | 3397 | ||
| 3398 | #ifdef WINDOWSNT | ||
| 3406 | retry_connect: | 3399 | retry_connect: |
| 3400 | #endif | ||
| 3407 | 3401 | ||
| 3408 | s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); | 3402 | s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol); |
| 3409 | if (s < 0) | 3403 | if (s < 0) |
| @@ -3467,7 +3461,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3467 | if (EQ (service, Qt)) | 3461 | if (EQ (service, Qt)) |
| 3468 | { | 3462 | { |
| 3469 | struct sockaddr_in sa1; | 3463 | struct sockaddr_in sa1; |
| 3470 | int len1 = sizeof (sa1); | 3464 | socklen_t len1 = sizeof (sa1); |
| 3471 | if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) | 3465 | if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) |
| 3472 | { | 3466 | { |
| 3473 | ((struct sockaddr_in *)(lres->ai_addr))->sin_port = sa1.sin_port; | 3467 | ((struct sockaddr_in *)(lres->ai_addr))->sin_port = sa1.sin_port; |
| @@ -3514,7 +3508,8 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3514 | /* Unlike most other syscalls connect() cannot be called | 3508 | /* Unlike most other syscalls connect() cannot be called |
| 3515 | again. (That would return EALREADY.) The proper way to | 3509 | again. (That would return EALREADY.) The proper way to |
| 3516 | wait for completion is select(). */ | 3510 | wait for completion is select(). */ |
| 3517 | int sc, len; | 3511 | int sc; |
| 3512 | socklen_t len; | ||
| 3518 | SELECT_TYPE fdset; | 3513 | SELECT_TYPE fdset; |
| 3519 | retry_select: | 3514 | retry_select: |
| 3520 | FD_ZERO (&fdset); | 3515 | FD_ZERO (&fdset); |
| @@ -3587,7 +3582,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3587 | if (!is_server) | 3582 | if (!is_server) |
| 3588 | { | 3583 | { |
| 3589 | struct sockaddr_in sa1; | 3584 | struct sockaddr_in sa1; |
| 3590 | int len1 = sizeof (sa1); | 3585 | socklen_t len1 = sizeof (sa1); |
| 3591 | if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) | 3586 | if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0) |
| 3592 | contact = Fplist_put (contact, QClocal, | 3587 | contact = Fplist_put (contact, QClocal, |
| 3593 | conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1)); | 3588 | conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1)); |
| @@ -3705,10 +3700,10 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3705 | 3700 | ||
| 3706 | { | 3701 | { |
| 3707 | /* Setup coding systems for communicating with the network stream. */ | 3702 | /* Setup coding systems for communicating with the network stream. */ |
| 3708 | struct gcpro gcpro1; | 3703 | struct gcpro inner_gcpro1; |
| 3709 | /* Qt denotes we have not yet called Ffind_operation_coding_system. */ | 3704 | /* Qt denotes we have not yet called Ffind_operation_coding_system. */ |
| 3710 | Lisp_Object coding_systems = Qt; | 3705 | Lisp_Object coding_systems = Qt; |
| 3711 | Lisp_Object args[5], val; | 3706 | Lisp_Object fargs[5], val; |
| 3712 | 3707 | ||
| 3713 | if (!NILP (tem)) | 3708 | if (!NILP (tem)) |
| 3714 | { | 3709 | { |
| @@ -3731,11 +3726,11 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3731 | coding_systems = Qnil; | 3726 | coding_systems = Qnil; |
| 3732 | else | 3727 | else |
| 3733 | { | 3728 | { |
| 3734 | args[0] = Qopen_network_stream, args[1] = name, | 3729 | fargs[0] = Qopen_network_stream, fargs[1] = name, |
| 3735 | args[2] = buffer, args[3] = host, args[4] = service; | 3730 | fargs[2] = buffer, fargs[3] = host, fargs[4] = service; |
| 3736 | GCPRO1 (proc); | 3731 | GCPRO1_VAR (proc, inner_gcpro); |
| 3737 | coding_systems = Ffind_operation_coding_system (5, args); | 3732 | coding_systems = Ffind_operation_coding_system (5, fargs); |
| 3738 | UNGCPRO; | 3733 | UNGCPRO_VAR (inner_gcpro); |
| 3739 | } | 3734 | } |
| 3740 | if (CONSP (coding_systems)) | 3735 | if (CONSP (coding_systems)) |
| 3741 | val = XCAR (coding_systems); | 3736 | val = XCAR (coding_systems); |
| @@ -3764,11 +3759,11 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3764 | coding_systems = Qnil; | 3759 | coding_systems = Qnil; |
| 3765 | else | 3760 | else |
| 3766 | { | 3761 | { |
| 3767 | args[0] = Qopen_network_stream, args[1] = name, | 3762 | fargs[0] = Qopen_network_stream, fargs[1] = name, |
| 3768 | args[2] = buffer, args[3] = host, args[4] = service; | 3763 | fargs[2] = buffer, fargs[3] = host, fargs[4] = service; |
| 3769 | GCPRO1 (proc); | 3764 | GCPRO1_VAR (proc, inner_gcpro); |
| 3770 | coding_systems = Ffind_operation_coding_system (5, args); | 3765 | coding_systems = Ffind_operation_coding_system (5, fargs); |
| 3771 | UNGCPRO; | 3766 | UNGCPRO_VAR (inner_gcpro); |
| 3772 | } | 3767 | } |
| 3773 | } | 3768 | } |
| 3774 | if (CONSP (coding_systems)) | 3769 | if (CONSP (coding_systems)) |
| @@ -3948,7 +3943,7 @@ FLAGS is the current flags of the interface. */) | |||
| 3948 | CHECK_STRING (ifname); | 3943 | CHECK_STRING (ifname); |
| 3949 | 3944 | ||
| 3950 | memset (rq.ifr_name, 0, sizeof rq.ifr_name); | 3945 | memset (rq.ifr_name, 0, sizeof rq.ifr_name); |
| 3951 | strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name)); | 3946 | strncpy (rq.ifr_name, SSDATA (ifname), sizeof (rq.ifr_name)); |
| 3952 | 3947 | ||
| 3953 | s = socket (AF_INET, SOCK_STREAM, 0); | 3948 | s = socket (AF_INET, SOCK_STREAM, 0); |
| 3954 | if (s < 0) | 3949 | if (s < 0) |
| @@ -4192,7 +4187,7 @@ server_accept_connection (Lisp_Object server, int channel) | |||
| 4192 | struct sockaddr_un un; | 4187 | struct sockaddr_un un; |
| 4193 | #endif | 4188 | #endif |
| 4194 | } saddr; | 4189 | } saddr; |
| 4195 | int len = sizeof saddr; | 4190 | socklen_t len = sizeof saddr; |
| 4196 | 4191 | ||
| 4197 | s = accept (channel, &saddr.sa, &len); | 4192 | s = accept (channel, &saddr.sa, &len); |
| 4198 | 4193 | ||
| @@ -4928,8 +4923,6 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, | |||
| 4928 | d->func (channel, d->data, 0); | 4923 | d->func (channel, d->data, 0); |
| 4929 | } | 4924 | } |
| 4930 | 4925 | ||
| 4931 | /* Really FIRST_PROC_DESC should be 0 on Unix, | ||
| 4932 | but this is safer in the short run. */ | ||
| 4933 | for (channel = 0; channel <= max_process_desc; channel++) | 4926 | for (channel = 0; channel <= max_process_desc; channel++) |
| 4934 | { | 4927 | { |
| 4935 | if (FD_ISSET (channel, &Available) | 4928 | if (FD_ISSET (channel, &Available) |
| @@ -5059,7 +5052,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd, | |||
| 5059 | /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. | 5052 | /* getsockopt(,,SO_ERROR,,) is said to hang on some systems. |
| 5060 | So only use it on systems where it is known to work. */ | 5053 | So only use it on systems where it is known to work. */ |
| 5061 | { | 5054 | { |
| 5062 | int xlen = sizeof (xerrno); | 5055 | socklen_t xlen = sizeof (xerrno); |
| 5063 | if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) | 5056 | if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen)) |
| 5064 | xerrno = errno; | 5057 | xerrno = errno; |
| 5065 | } | 5058 | } |
| @@ -5128,9 +5121,9 @@ read_process_output_call (Lisp_Object fun_and_args) | |||
| 5128 | } | 5121 | } |
| 5129 | 5122 | ||
| 5130 | static Lisp_Object | 5123 | static Lisp_Object |
| 5131 | read_process_output_error_handler (Lisp_Object error) | 5124 | read_process_output_error_handler (Lisp_Object error_val) |
| 5132 | { | 5125 | { |
| 5133 | cmd_error_internal (error, "error in process filter: "); | 5126 | cmd_error_internal (error_val, "error in process filter: "); |
| 5134 | Vinhibit_quit = Qt; | 5127 | Vinhibit_quit = Qt; |
| 5135 | update_echo_area (); | 5128 | update_echo_area (); |
| 5136 | Fsleep_for (make_number (2), Qnil); | 5129 | Fsleep_for (make_number (2), Qnil); |
| @@ -5171,7 +5164,7 @@ read_process_output (Lisp_Object proc, register int channel) | |||
| 5171 | /* We have a working select, so proc_buffered_char is always -1. */ | 5164 | /* We have a working select, so proc_buffered_char is always -1. */ |
| 5172 | if (DATAGRAM_CHAN_P (channel)) | 5165 | if (DATAGRAM_CHAN_P (channel)) |
| 5173 | { | 5166 | { |
| 5174 | int len = datagram_address[channel].len; | 5167 | socklen_t len = datagram_address[channel].len; |
| 5175 | nbytes = recvfrom (channel, chars + carryover, readmax, | 5168 | nbytes = recvfrom (channel, chars + carryover, readmax, |
| 5176 | 0, datagram_address[channel].sa, &len); | 5169 | 0, datagram_address[channel].sa, &len); |
| 5177 | } | 5170 | } |
| @@ -5925,7 +5918,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group, | |||
| 5925 | 5918 | ||
| 5926 | if (sig_char && *sig_char != CDISABLE) | 5919 | if (sig_char && *sig_char != CDISABLE) |
| 5927 | { | 5920 | { |
| 5928 | send_process (proc, sig_char, 1, Qnil); | 5921 | send_process (proc, (char *) sig_char, 1, Qnil); |
| 5929 | return; | 5922 | return; |
| 5930 | } | 5923 | } |
| 5931 | /* If we can't send the signal with a character, | 5924 | /* If we can't send the signal with a character, |
| @@ -6534,9 +6527,9 @@ exec_sentinel_unwind (Lisp_Object data) | |||
| 6534 | } | 6527 | } |
| 6535 | 6528 | ||
| 6536 | static Lisp_Object | 6529 | static Lisp_Object |
| 6537 | exec_sentinel_error_handler (Lisp_Object error) | 6530 | exec_sentinel_error_handler (Lisp_Object error_val) |
| 6538 | { | 6531 | { |
| 6539 | cmd_error_internal (error, "error in process sentinel: "); | 6532 | cmd_error_internal (error_val, "error in process sentinel: "); |
| 6540 | Vinhibit_quit = Qt; | 6533 | Vinhibit_quit = Qt; |
| 6541 | update_echo_area (); | 6534 | update_echo_area (); |
| 6542 | Fsleep_for (make_number (2), Qnil); | 6535 | Fsleep_for (make_number (2), Qnil); |