moss@brl.mil (Gary S. Moss (VLD/VMB) <moss>) (02/06/91)
Ok, here's one, I had a need to set up an error handler via XSetErrorHandler to trap Xerrors so that my application (actually Rob Pike's sam editor that I'm porting to color X servers) could kill the parent process before exiting; otherwise the parent process would hang around indefinitely. I really wanted to duplicate the error diagnostic reported by mit/lib/X/XlibInt.c/_XPrintDefaultError(), but as far as I know it is unadvertised, therefore unsupported. For now, I am using it with compiler flags configurable in the makefile ready to punt if it becomes unavailable. Can someone at MIT advise me on this, or consider promoting it to a documented Xlib entry point in R5? Thanks, -Gary
mouse@lightning.mcrcim.mcgill.EDU (02/07/91)
> I had a need to set up an error handler via XSetErrorHandler to trap > Xerrors so that my application ([...]) could kill the parent process > before exiting; otherwise the parent process would hang around > indefinitely. I really wanted to duplicate the error diagnostic > reported by mit/lib/X/XlibInt.c/_XPrintDefaultError(), but as far as > I know it is unadvertised, therefore unsupported. For now, I am > using it with compiler flags configurable in the makefile ready to > punt if it becomes unavailable. > Can someone at MIT advise me on this, or consider promoting it to a > documented Xlib entry point in R5? Well, I'm not at MIT, but perhaps I'll do :-) You don't need a documented entry point. Instead, save the pointer returned by XSetErrorHandler and call through that to get what you want. That is, your error handler should look something like int (*prevhand)(); /* pointer to previous handler */ errhand(disp,ev) Display *disp; XErrorEvent *ev; { ...look at things, perhaps return if you want to ignore the error, perhaps kill off your other process... (*prevhand)(disp,ev); /* call previous handler */ } ...and in your setup code, prevhand = XSetErrorHandler(errhand); /* install our handler */ der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu