diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/process.c b/src/process.c index ad637ad6cfa..2e41267479c 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1267,7 +1267,7 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1267 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ | 1267 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ |
| 1268 | { | 1268 | { |
| 1269 | register struct Lisp_Vector *p = XVECTOR (address); | 1269 | register struct Lisp_Vector *p = XVECTOR (address); |
| 1270 | Lisp_Object args[6]; | 1270 | Lisp_Object args[10]; |
| 1271 | int nargs, i; | 1271 | int nargs, i; |
| 1272 | 1272 | ||
| 1273 | if (p->size == 4 || (p->size == 5 && !NILP (omit_port))) | 1273 | if (p->size == 4 || (p->size == 5 && !NILP (omit_port))) |
| @@ -1294,7 +1294,20 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1294 | return Qnil; | 1294 | return Qnil; |
| 1295 | 1295 | ||
| 1296 | for (i = 0; i < nargs; i++) | 1296 | for (i = 0; i < nargs; i++) |
| 1297 | args[i+1] = p->contents[i]; | 1297 | { |
| 1298 | EMACS_INT element = XINT (p->contents[i]); | ||
| 1299 | |||
| 1300 | if (element < 0 || element > 65535) | ||
| 1301 | return Qnil; | ||
| 1302 | |||
| 1303 | if (nargs <= 5 /* IPv4 */ | ||
| 1304 | && i < 4 /* host, not port */ | ||
| 1305 | && element > 255) | ||
| 1306 | return Qnil; | ||
| 1307 | |||
| 1308 | args[i+1] = p->contents[i]; | ||
| 1309 | } | ||
| 1310 | |||
| 1298 | return Fformat (nargs+1, args); | 1311 | return Fformat (nargs+1, args); |
| 1299 | } | 1312 | } |
| 1300 | 1313 | ||
| @@ -1304,7 +1317,6 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1304 | args[0] = build_string ("<Family %d>"); | 1317 | args[0] = build_string ("<Family %d>"); |
| 1305 | args[1] = Fcar (address); | 1318 | args[1] = Fcar (address); |
| 1306 | return Fformat (2, args); | 1319 | return Fformat (2, args); |
| 1307 | |||
| 1308 | } | 1320 | } |
| 1309 | 1321 | ||
| 1310 | return Qnil; | 1322 | return Qnil; |
| @@ -1410,7 +1422,6 @@ list_processes_1 (query_only) | |||
| 1410 | if (CONSP (p->status)) | 1422 | if (CONSP (p->status)) |
| 1411 | symbol = XCAR (p->status); | 1423 | symbol = XCAR (p->status); |
| 1412 | 1424 | ||
| 1413 | |||
| 1414 | if (EQ (symbol, Qsignal)) | 1425 | if (EQ (symbol, Qsignal)) |
| 1415 | { | 1426 | { |
| 1416 | Lisp_Object tem; | 1427 | Lisp_Object tem; |
| @@ -4805,8 +4816,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4805 | subprocess termination and SIGCHLD. */ | 4816 | subprocess termination and SIGCHLD. */ |
| 4806 | else if (nread == 0 && !NETCONN_P (proc)) | 4817 | else if (nread == 0 && !NETCONN_P (proc)) |
| 4807 | ; | 4818 | ; |
| 4808 | #endif /* O_NDELAY */ | 4819 | #endif /* O_NDELAY */ |
| 4809 | #endif /* O_NONBLOCK */ | 4820 | #endif /* O_NONBLOCK */ |
| 4810 | #ifdef HAVE_PTYS | 4821 | #ifdef HAVE_PTYS |
| 4811 | /* On some OSs with ptys, when the process on one end of | 4822 | /* On some OSs with ptys, when the process on one end of |
| 4812 | a pty exits, the other end gets an error reading with | 4823 | a pty exits, the other end gets an error reading with |
| @@ -4817,11 +4828,17 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4817 | get a SIGCHLD). | 4828 | get a SIGCHLD). |
| 4818 | 4829 | ||
| 4819 | However, it has been known to happen that the SIGCHLD | 4830 | However, it has been known to happen that the SIGCHLD |
| 4820 | got lost. So raise the signl again just in case. | 4831 | got lost. So raise the signal again just in case. |
| 4821 | It can't hurt. */ | 4832 | It can't hurt. */ |
| 4822 | else if (nread == -1 && errno == EIO) | 4833 | else if (nread == -1 && errno == EIO) |
| 4823 | kill (getpid (), SIGCHLD); | 4834 | { |
| 4824 | #endif /* HAVE_PTYS */ | 4835 | /* Clear the descriptor now, so we only raise the signal once. */ |
| 4836 | FD_CLR (channel, &input_wait_mask); | ||
| 4837 | FD_CLR (channel, &non_keyboard_wait_mask); | ||
| 4838 | |||
| 4839 | kill (getpid (), SIGCHLD); | ||
| 4840 | } | ||
| 4841 | #endif /* HAVE_PTYS */ | ||
| 4825 | /* If we can detect process termination, don't consider the process | 4842 | /* If we can detect process termination, don't consider the process |
| 4826 | gone just because its pipe is closed. */ | 4843 | gone just because its pipe is closed. */ |
| 4827 | #ifdef SIGCHLD | 4844 | #ifdef SIGCHLD |
| @@ -6407,17 +6424,12 @@ sigchld_handler (signo) | |||
| 6407 | #define WUNTRACED 0 | 6424 | #define WUNTRACED 0 |
| 6408 | #endif /* no WUNTRACED */ | 6425 | #endif /* no WUNTRACED */ |
| 6409 | /* Keep trying to get a status until we get a definitive result. */ | 6426 | /* Keep trying to get a status until we get a definitive result. */ |
| 6410 | while (1) | 6427 | do |
| 6411 | { | 6428 | { |
| 6412 | errno = 0; | 6429 | errno = 0; |
| 6413 | pid = wait3 (&w, WNOHANG | WUNTRACED, 0); | 6430 | pid = wait3 (&w, WNOHANG | WUNTRACED, 0); |
| 6414 | if (! (pid < 0 && errno == EINTR)) | ||
| 6415 | break; | ||
| 6416 | /* Avoid a busyloop: wait3 is a system call, so we do not want | ||
| 6417 | to prevent the kernel from actually sending SIGCHLD to emacs | ||
| 6418 | by asking for it all the time. */ | ||
| 6419 | sleep (1); | ||
| 6420 | } | 6431 | } |
| 6432 | while (pid < 0 && errno == EINTR); | ||
| 6421 | 6433 | ||
| 6422 | if (pid <= 0) | 6434 | if (pid <= 0) |
| 6423 | { | 6435 | { |