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 6d84d4c4a87..56e4335ca2c 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1268,7 +1268,7 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1268 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ | 1268 | if (VECTORP (address)) /* AF_INET or AF_INET6 */ |
| 1269 | { | 1269 | { |
| 1270 | register struct Lisp_Vector *p = XVECTOR (address); | 1270 | register struct Lisp_Vector *p = XVECTOR (address); |
| 1271 | Lisp_Object args[6]; | 1271 | Lisp_Object args[10]; |
| 1272 | int nargs, i; | 1272 | int nargs, i; |
| 1273 | 1273 | ||
| 1274 | if (p->size == 4 || (p->size == 5 && !NILP (omit_port))) | 1274 | if (p->size == 4 || (p->size == 5 && !NILP (omit_port))) |
| @@ -1295,7 +1295,20 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1295 | return Qnil; | 1295 | return Qnil; |
| 1296 | 1296 | ||
| 1297 | for (i = 0; i < nargs; i++) | 1297 | for (i = 0; i < nargs; i++) |
| 1298 | args[i+1] = p->contents[i]; | 1298 | { |
| 1299 | EMACS_INT element = XINT (p->contents[i]); | ||
| 1300 | |||
| 1301 | if (element < 0 || element > 65535) | ||
| 1302 | return Qnil; | ||
| 1303 | |||
| 1304 | if (nargs <= 5 /* IPv4 */ | ||
| 1305 | && i < 4 /* host, not port */ | ||
| 1306 | && element > 255) | ||
| 1307 | return Qnil; | ||
| 1308 | |||
| 1309 | args[i+1] = p->contents[i]; | ||
| 1310 | } | ||
| 1311 | |||
| 1299 | return Fformat (nargs+1, args); | 1312 | return Fformat (nargs+1, args); |
| 1300 | } | 1313 | } |
| 1301 | 1314 | ||
| @@ -1305,7 +1318,6 @@ Returns nil if format of ADDRESS is invalid. */) | |||
| 1305 | args[0] = build_string ("<Family %d>"); | 1318 | args[0] = build_string ("<Family %d>"); |
| 1306 | args[1] = Fcar (address); | 1319 | args[1] = Fcar (address); |
| 1307 | return Fformat (2, args); | 1320 | return Fformat (2, args); |
| 1308 | |||
| 1309 | } | 1321 | } |
| 1310 | 1322 | ||
| 1311 | return Qnil; | 1323 | return Qnil; |
| @@ -1411,7 +1423,6 @@ list_processes_1 (query_only) | |||
| 1411 | if (CONSP (p->status)) | 1423 | if (CONSP (p->status)) |
| 1412 | symbol = XCAR (p->status); | 1424 | symbol = XCAR (p->status); |
| 1413 | 1425 | ||
| 1414 | |||
| 1415 | if (EQ (symbol, Qsignal)) | 1426 | if (EQ (symbol, Qsignal)) |
| 1416 | { | 1427 | { |
| 1417 | Lisp_Object tem; | 1428 | Lisp_Object tem; |
| @@ -4811,8 +4822,8 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4811 | subprocess termination and SIGCHLD. */ | 4822 | subprocess termination and SIGCHLD. */ |
| 4812 | else if (nread == 0 && !NETCONN_P (proc)) | 4823 | else if (nread == 0 && !NETCONN_P (proc)) |
| 4813 | ; | 4824 | ; |
| 4814 | #endif /* O_NDELAY */ | 4825 | #endif /* O_NDELAY */ |
| 4815 | #endif /* O_NONBLOCK */ | 4826 | #endif /* O_NONBLOCK */ |
| 4816 | #ifdef HAVE_PTYS | 4827 | #ifdef HAVE_PTYS |
| 4817 | /* On some OSs with ptys, when the process on one end of | 4828 | /* On some OSs with ptys, when the process on one end of |
| 4818 | a pty exits, the other end gets an error reading with | 4829 | a pty exits, the other end gets an error reading with |
| @@ -4823,11 +4834,17 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4823 | get a SIGCHLD). | 4834 | get a SIGCHLD). |
| 4824 | 4835 | ||
| 4825 | However, it has been known to happen that the SIGCHLD | 4836 | However, it has been known to happen that the SIGCHLD |
| 4826 | got lost. So raise the signl again just in case. | 4837 | got lost. So raise the signal again just in case. |
| 4827 | It can't hurt. */ | 4838 | It can't hurt. */ |
| 4828 | else if (nread == -1 && errno == EIO) | 4839 | else if (nread == -1 && errno == EIO) |
| 4829 | kill (getpid (), SIGCHLD); | 4840 | { |
| 4830 | #endif /* HAVE_PTYS */ | 4841 | /* Clear the descriptor now, so we only raise the signal once. */ |
| 4842 | FD_CLR (channel, &input_wait_mask); | ||
| 4843 | FD_CLR (channel, &non_keyboard_wait_mask); | ||
| 4844 | |||
| 4845 | kill (getpid (), SIGCHLD); | ||
| 4846 | } | ||
| 4847 | #endif /* HAVE_PTYS */ | ||
| 4831 | /* If we can detect process termination, don't consider the process | 4848 | /* If we can detect process termination, don't consider the process |
| 4832 | gone just because its pipe is closed. */ | 4849 | gone just because its pipe is closed. */ |
| 4833 | #ifdef SIGCHLD | 4850 | #ifdef SIGCHLD |
| @@ -6506,17 +6523,12 @@ sigchld_handler (signo) | |||
| 6506 | #define WUNTRACED 0 | 6523 | #define WUNTRACED 0 |
| 6507 | #endif /* no WUNTRACED */ | 6524 | #endif /* no WUNTRACED */ |
| 6508 | /* Keep trying to get a status until we get a definitive result. */ | 6525 | /* Keep trying to get a status until we get a definitive result. */ |
| 6509 | while (1) | 6526 | do |
| 6510 | { | 6527 | { |
| 6511 | errno = 0; | 6528 | errno = 0; |
| 6512 | pid = wait3 (&w, WNOHANG | WUNTRACED, 0); | 6529 | pid = wait3 (&w, WNOHANG | WUNTRACED, 0); |
| 6513 | if (! (pid < 0 && errno == EINTR)) | ||
| 6514 | break; | ||
| 6515 | /* Avoid a busyloop: wait3 is a system call, so we do not want | ||
| 6516 | to prevent the kernel from actually sending SIGCHLD to emacs | ||
| 6517 | by asking for it all the time. */ | ||
| 6518 | sleep (1); | ||
| 6519 | } | 6530 | } |
| 6531 | while (pid < 0 && errno == EINTR); | ||
| 6520 | 6532 | ||
| 6521 | if (pid <= 0) | 6533 | if (pid <= 0) |
| 6522 | { | 6534 | { |