Subject: Re: bug#16093: 24.3.50; Crash of emacs --daemon on killing X server

From: Jan Djärv <[email-masked]>
Date: Tue, 10 Dec 2013 20:43:58 +0100

Hello.

9 dec 2013 kl. 18:57 skrev Dmitry Antipov <[email-masked]>:

> On 12/09/2013 07:58 PM, Nix wrote:
>> 
>> Start emacs --daemon (using the lucid toolkit), under X. Shut X down.
>> Emacs crashes shortly afterwards.
>> 
>> 
>> The lack of symbol table info is concerning (obviously my gdb has
>> forgotten how to look up separated debug info *yet again*), but I don't
>> think that important, since the death site is after a (garbage-collect)
>> thus not in Lisp-land anyway. Obviously no xbacktrace is possible: the
>> process is dead.
>> 
>> It is fairly clear that we should not be calling xftfont_close() if the
>> X server is not there! Why has this started happening?
> 
> Hm... IIUC there is no convenient way to check whether X display connection
> is alive. But we can do some tricks, for example, try to select() or poll()
> ConnectionNumber() - if there is no EBADF, X server is hopefully present...

Well, file descriptors are reused, so it may be used for something else and give a false positive.
To do this properly we would need some kind of cleanup function that is called when the display goes away.

	Jan D.