Mercurial > emacs
comparison src/xterm.c @ 34956:c26b7651dd9f
(x_connection_closed): Catch X errors around all
statements that call X. Save away the error message in a local
copy.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 02 Jan 2001 13:57:17 +0000 |
parents | bbd0e7b5043a |
children | 3984e029f738 |
comparison
equal
deleted
inserted
replaced
34955:efabd2ba9997 | 34956:c26b7651dd9f |
---|---|
11248 /* USG systems forget handlers when they are used; | 11248 /* USG systems forget handlers when they are used; |
11249 must reestablish each time */ | 11249 must reestablish each time */ |
11250 signal (signalnum, x_connection_signal); | 11250 signal (signalnum, x_connection_signal); |
11251 #endif /* USG */ | 11251 #endif /* USG */ |
11252 } | 11252 } |
11253 | |
11253 | 11254 |
11254 /* Handling X errors. */ | 11255 /************************************************************************ |
11255 | 11256 Handling X errors |
11256 /* Handle the loss of connection to display DISPLAY. */ | 11257 ************************************************************************/ |
11258 | |
11259 /* Handle the loss of connection to display DPY. ERROR_MESSAGE is | |
11260 the text of an error message that lead to the connection loss. */ | |
11257 | 11261 |
11258 static SIGTYPE | 11262 static SIGTYPE |
11259 x_connection_closed (dpy, error_message) | 11263 x_connection_closed (dpy, error_message) |
11260 Display *dpy; | 11264 Display *dpy; |
11261 char *error_message; | 11265 char *error_message; |
11262 { | 11266 { |
11263 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); | 11267 struct x_display_info *dpyinfo = x_display_info_for_display (dpy); |
11264 Lisp_Object frame, tail; | 11268 Lisp_Object frame, tail; |
11265 | 11269 int count; |
11270 char *msg; | |
11271 | |
11272 msg = (char *) alloca (strlen (error_message) + 1); | |
11273 strcpy (msg, error_message); | |
11266 handling_signal = 0; | 11274 handling_signal = 0; |
11275 | |
11276 /* Prevent being called recursively because of an error condition | |
11277 below. Otherwise, we might end up with printing ``can't find per | |
11278 display information'' in the recursive call instead of printing | |
11279 the original message here. */ | |
11280 count = x_catch_errors (dpy); | |
11267 | 11281 |
11268 /* We have to close the display to inform Xt that it doesn't | 11282 /* We have to close the display to inform Xt that it doesn't |
11269 exist anymore. If we don't, Xt will continue to wait for | 11283 exist anymore. If we don't, Xt will continue to wait for |
11270 events from the display. As a consequence, a sequence of | 11284 events from the display. As a consequence, a sequence of |
11271 | 11285 |
11279 Closing the display is reported to lead to a bus error on | 11293 Closing the display is reported to lead to a bus error on |
11280 OpenWindows in certain situations. I suspect that is a bug | 11294 OpenWindows in certain situations. I suspect that is a bug |
11281 in OpenWindows. I don't know how to cicumvent it here. */ | 11295 in OpenWindows. I don't know how to cicumvent it here. */ |
11282 | 11296 |
11283 #ifdef USE_X_TOOLKIT | 11297 #ifdef USE_X_TOOLKIT |
11284 { | 11298 XtCloseDisplay (dpy); |
11285 /* Prevent being called recursively because of an error condition | |
11286 in XtCloseDisplay. Otherwise, we might end up with printing | |
11287 ``can't find per display information'' in the recursive call | |
11288 instead of printing the original message here. */ | |
11289 int count = x_catch_errors (dpy); | |
11290 XtCloseDisplay (dpy); | |
11291 x_uncatch_errors (dpy, count); | |
11292 } | |
11293 #endif | 11299 #endif |
11294 | 11300 |
11295 /* Indicate that this display is dead. */ | 11301 /* Indicate that this display is dead. */ |
11296 if (dpyinfo) | 11302 if (dpyinfo) |
11297 dpyinfo->display = 0; | 11303 dpyinfo->display = 0; |
11324 } | 11330 } |
11325 | 11331 |
11326 if (dpyinfo) | 11332 if (dpyinfo) |
11327 x_delete_display (dpyinfo); | 11333 x_delete_display (dpyinfo); |
11328 | 11334 |
11335 x_uncatch_errors (dpy, count); | |
11336 | |
11329 if (x_display_list == 0) | 11337 if (x_display_list == 0) |
11330 { | 11338 { |
11331 fprintf (stderr, "%s\n", error_message); | 11339 fprintf (stderr, "%s\n", msg); |
11332 shut_down_emacs (0, 0, Qnil); | 11340 shut_down_emacs (0, 0, Qnil); |
11333 exit (70); | 11341 exit (70); |
11334 } | 11342 } |
11335 | 11343 |
11336 /* Ordinary stack unwind doesn't deal with these. */ | 11344 /* Ordinary stack unwind doesn't deal with these. */ |
11339 #endif | 11347 #endif |
11340 sigunblock (sigmask (SIGALRM)); | 11348 sigunblock (sigmask (SIGALRM)); |
11341 TOTALLY_UNBLOCK_INPUT; | 11349 TOTALLY_UNBLOCK_INPUT; |
11342 | 11350 |
11343 clear_waiting_for_input (); | 11351 clear_waiting_for_input (); |
11344 error ("%s", error_message); | 11352 error ("%s", msg); |
11345 } | 11353 } |
11354 | |
11346 | 11355 |
11347 /* This is the usual handler for X protocol errors. | 11356 /* This is the usual handler for X protocol errors. |
11348 It kills all frames on the display that we got the error for. | 11357 It kills all frames on the display that we got the error for. |
11349 If that was the only one, it prints an error message and kills Emacs. */ | 11358 If that was the only one, it prints an error message and kills Emacs. */ |
11350 | 11359 |
11361 XGetErrorText (display, error->error_code, buf, sizeof (buf)); | 11370 XGetErrorText (display, error->error_code, buf, sizeof (buf)); |
11362 sprintf (buf1, "X protocol error: %s on protocol request %d", | 11371 sprintf (buf1, "X protocol error: %s on protocol request %d", |
11363 buf, error->request_code); | 11372 buf, error->request_code); |
11364 x_connection_closed (display, buf1); | 11373 x_connection_closed (display, buf1); |
11365 } | 11374 } |
11375 | |
11366 | 11376 |
11367 /* This is the first-level handler for X protocol errors. | 11377 /* This is the first-level handler for X protocol errors. |
11368 It calls x_error_quitter or x_error_catcher. */ | 11378 It calls x_error_quitter or x_error_catcher. */ |
11369 | 11379 |
11370 static int | 11380 static int |