Am Samstag, 27. Mai 2006 14:57 schrieb Abdelrazak Younes: > I have maybe an idea. Peter Kummel claims the following in his Cmake patch: > > ------------------------------------------------------------------- > and this fixes the crash on exit under windows, maybe > lyx_gui::unregister_socket_callback(fd_) is broken under windows. > -------------------------------------------------------------------
This is something completely different and does not help on linux, because fd_ is only -1 on windows where we don't have support for sockets. I am going to commit the attached patch, that fixes the crash and while I was at it I also added checks for the close() return value as recommended by the man page. Georg Log: * src/lyxsocket.C (LyXServerSocket::~LyXServerSocket): Don't try to unregister and close fd_ if the socket is disabled (avoids crash on win, from Peter Kümmel) (LyXServerSocket::~LyXServerSocket): Check the return value of close() (LyXDataSocket::~LyXDataSocket): ditto
Index: src/lyxsocket.C =================================================================== --- src/lyxsocket.C (Revision 13939) +++ src/lyxsocket.C (Arbeitskopie) @@ -74,8 +74,12 @@ LyXServerSocket::LyXServerSocket(LyXFunc // Close the socket and remove the address of the filesystem. LyXServerSocket::~LyXServerSocket() { - lyx_gui::unregister_socket_callback(fd_); - ::close(fd_); + if (fd_ != -1) { + lyx_gui::unregister_socket_callback(fd_); + if (::close(fd_) != 0) + lyxerr << "lyx: Server socket " << fd_ + << " IO error on closing: " << strerror(errno); + } lyx::support::unlink(address_); lyxerr[Debug::LYXSERVER] << "lyx: Server socket quitting" << endl; } @@ -201,7 +205,9 @@ LyXDataSocket::LyXDataSocket(int fd) LyXDataSocket::~LyXDataSocket() { - ::close(fd_); + if (::close(fd_) != 0) + lyxerr << "lyx: Data socket " << fd_ + << " IO error on closing: " << strerror(errno); lyx_gui::unregister_socket_callback(fd_); lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."