- if (!ready) {
- lyxerr << "LyXComm: Already disconnected" << endl;
- return;
- }
-
- if(infd > -1) {
- fl_remove_io_callback(infd, FL_READ, C_LyXComm_callback);
-
- string tmp = pipename + ".in";
-#ifdef __EMX__ // Notify the operating system.
- rc = DosDisConnectNPipe(infd);
- if (rc != NO_ERROR) {
- errnum = TranslateOS2Error(rc);
- lyxerr << "LyXComm: Could not disconnect pipe " << tmp
- << '\n' << strerror(errnum) << endl;
- return;
- }
-#endif
- if (close(infd) < 0) {
- lyxerr << "LyXComm: Could not close pipe " << tmp
- << '\n' << strerror(errno) << endl;
- }
-#ifndef __EMX__ // OS/2 named pipes will be automatically removed.
- if (lyx::unlink(tmp) < 0){
- lyxerr << "LyXComm: Could not remove pipe " << tmp
- << '\n' << strerror(errno) << endl;
- };
-#endif
- }
- if(outfd > -1) {
- string tmp = pipename + ".out";
-#ifdef __EMX__
- rc = DosDisConnectNPipe(outfd);
- if (rc != NO_ERROR) {
- errnum = TranslateOS2Error(rc);
- lyxerr << "LyXComm: Could not disconnect pipe " << tmp
- << '\n' << strerror(errnum) << endl;
- return;
- }
-#endif
- if (::close(outfd) < 0) {
- lyxerr << "LyXComm: Could not close pipe " << tmp
- << '\n' << strerror(errno) << endl;
- }
-#ifndef __EMX__
- if (lyx::unlink(tmp) < 0){
- lyxerr << "LyXComm: Could not remove pipe " << tmp
- << '\n' << strerror(errno) << endl;
- };
-#endif
+void LyXComm::emergencyCleanup()
+{
+ if (!pipename.empty()) {
+ endPipe(infd, inPipeName(), false);
+ endPipe(outfd, outPipeName(), true);