diff options
| author | Eli Zaretskii | 2013-12-15 20:37:48 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-12-15 20:37:48 +0200 |
| commit | 1014b1dc34ed9717c48a089f45423235f09b1101 (patch) | |
| tree | b3aeeca9983ed8082fb46f2981d30ef58696b17c /src/process.c | |
| parent | e088f894144198abdbf58bf41a5e7a6b6499fda6 (diff) | |
| download | emacs-1014b1dc34ed9717c48a089f45423235f09b1101.tar.gz emacs-1014b1dc34ed9717c48a089f45423235f09b1101.zip | |
Fix bug #16152 with crashes in process-send-eof on MS-Windows.
src/process.c (Fprocess_send_eof): Don't crash if someone tries to
open a pty on MS-Windows.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/process.c b/src/process.c index 7050bf9822e..dac4b14dcea 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -6032,13 +6032,16 @@ process has been transmitted to the serial port. */) | |||
| 6032 | (Lisp_Object process) | 6032 | (Lisp_Object process) |
| 6033 | { | 6033 | { |
| 6034 | Lisp_Object proc; | 6034 | Lisp_Object proc; |
| 6035 | struct coding_system *coding; | 6035 | struct coding_system *coding = NULL; |
| 6036 | int outfd; | ||
| 6036 | 6037 | ||
| 6037 | if (DATAGRAM_CONN_P (process)) | 6038 | if (DATAGRAM_CONN_P (process)) |
| 6038 | return process; | 6039 | return process; |
| 6039 | 6040 | ||
| 6040 | proc = get_process (process); | 6041 | proc = get_process (process); |
| 6041 | coding = proc_encode_coding_system[XPROCESS (proc)->outfd]; | 6042 | outfd = XPROCESS (proc)->outfd; |
| 6043 | if (outfd >= 0) | ||
| 6044 | coding = proc_encode_coding_system[outfd]; | ||
| 6042 | 6045 | ||
| 6043 | /* Make sure the process is really alive. */ | 6046 | /* Make sure the process is really alive. */ |
| 6044 | if (XPROCESS (proc)->raw_status_new) | 6047 | if (XPROCESS (proc)->raw_status_new) |
| @@ -6046,7 +6049,7 @@ process has been transmitted to the serial port. */) | |||
| 6046 | if (! EQ (XPROCESS (proc)->status, Qrun)) | 6049 | if (! EQ (XPROCESS (proc)->status, Qrun)) |
| 6047 | error ("Process %s not running", SDATA (XPROCESS (proc)->name)); | 6050 | error ("Process %s not running", SDATA (XPROCESS (proc)->name)); |
| 6048 | 6051 | ||
| 6049 | if (CODING_REQUIRE_FLUSHING (coding)) | 6052 | if (coding && CODING_REQUIRE_FLUSHING (coding)) |
| 6050 | { | 6053 | { |
| 6051 | coding->mode |= CODING_MODE_LAST_BLOCK; | 6054 | coding->mode |= CODING_MODE_LAST_BLOCK; |
| 6052 | send_process (proc, "", 0, Qnil); | 6055 | send_process (proc, "", 0, Qnil); |
| @@ -6064,7 +6067,8 @@ process has been transmitted to the serial port. */) | |||
| 6064 | } | 6067 | } |
| 6065 | else | 6068 | else |
| 6066 | { | 6069 | { |
| 6067 | int old_outfd = XPROCESS (proc)->outfd; | 6070 | struct Lisp_Process *p = XPROCESS (proc); |
| 6071 | int old_outfd = p->outfd; | ||
| 6068 | int new_outfd; | 6072 | int new_outfd; |
| 6069 | 6073 | ||
| 6070 | #ifdef HAVE_SHUTDOWN | 6074 | #ifdef HAVE_SHUTDOWN |
| @@ -6072,24 +6076,30 @@ process has been transmitted to the serial port. */) | |||
| 6072 | for communication with the subprocess, call shutdown to cause EOF. | 6076 | for communication with the subprocess, call shutdown to cause EOF. |
| 6073 | (In some old system, shutdown to socketpair doesn't work. | 6077 | (In some old system, shutdown to socketpair doesn't work. |
| 6074 | Then we just can't win.) */ | 6078 | Then we just can't win.) */ |
| 6075 | if (EQ (XPROCESS (proc)->type, Qnetwork) | 6079 | if (EQ (p->type, Qnetwork) |
| 6076 | || XPROCESS (proc)->infd == old_outfd) | 6080 | || p->infd == old_outfd) |
| 6077 | shutdown (old_outfd, 1); | 6081 | shutdown (old_outfd, 1); |
| 6078 | #endif | 6082 | #endif |
| 6079 | close_process_fd (&XPROCESS (proc)->open_fd[WRITE_TO_SUBPROCESS]); | 6083 | close_process_fd (&p->open_fd[WRITE_TO_SUBPROCESS]); |
| 6080 | new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); | 6084 | new_outfd = emacs_open (NULL_DEVICE, O_WRONLY, 0); |
| 6081 | if (new_outfd < 0) | 6085 | if (new_outfd < 0) |
| 6082 | report_file_error ("Opening null device", Qnil); | 6086 | report_file_error ("Opening null device", Qnil); |
| 6083 | XPROCESS (proc)->open_fd[WRITE_TO_SUBPROCESS] = new_outfd; | 6087 | p->open_fd[WRITE_TO_SUBPROCESS] = new_outfd; |
| 6084 | XPROCESS (proc)->outfd = new_outfd; | 6088 | p->outfd = new_outfd; |
| 6085 | 6089 | ||
| 6086 | if (!proc_encode_coding_system[new_outfd]) | 6090 | if (!proc_encode_coding_system[new_outfd]) |
| 6087 | proc_encode_coding_system[new_outfd] | 6091 | proc_encode_coding_system[new_outfd] |
| 6088 | = xmalloc (sizeof (struct coding_system)); | 6092 | = xmalloc (sizeof (struct coding_system)); |
| 6089 | *proc_encode_coding_system[new_outfd] | 6093 | if (old_outfd >= 0) |
| 6090 | = *proc_encode_coding_system[old_outfd]; | 6094 | { |
| 6091 | memset (proc_encode_coding_system[old_outfd], 0, | 6095 | *proc_encode_coding_system[new_outfd] |
| 6092 | sizeof (struct coding_system)); | 6096 | = *proc_encode_coding_system[old_outfd]; |
| 6097 | memset (proc_encode_coding_system[old_outfd], 0, | ||
| 6098 | sizeof (struct coding_system)); | ||
| 6099 | } | ||
| 6100 | else | ||
| 6101 | setup_coding_system (p->encode_coding_system, | ||
| 6102 | proc_encode_coding_system[new_outfd]); | ||
| 6093 | } | 6103 | } |
| 6094 | return process; | 6104 | return process; |
| 6095 | } | 6105 | } |