add the errno information onto the IPC, in case of a failure.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
@@ -471,7 +472,7 @@ void PmuppGui::aboutToQuit()
|
||||
msqid = msgget(key, flags | S_IRUSR | S_IWUSR);
|
||||
if (msqid != -1) {
|
||||
if (msgctl(msqid, IPC_RMID, NULL) == -1) {
|
||||
std::cerr << "**ERROR** couldn't removed the message queue (msqid=" << msqid << ")." << std::endl << std::endl;
|
||||
std::cerr << "**ERROR** couldn't removed the message queue (msqid=" << msqid << ", " << std::strerror(errno) << ")." << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2376,7 +2377,7 @@ void PmuppGui::plot()
|
||||
|
||||
key = ftok(QCoreApplication::applicationFilePath().toLatin1().data(), fMuppInstance);
|
||||
if (key == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't obtain necessary key to install the IPC message queue.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't obtain necessary key to install the IPC message queue (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2386,7 +2387,7 @@ void PmuppGui::plot()
|
||||
// open the message queue
|
||||
msqid = msgget(key, flags | S_IRUSR | S_IWUSR);
|
||||
if (msqid == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't open the IPC message queue.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't open the IPC message queue (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2395,7 +2396,7 @@ void PmuppGui::plot()
|
||||
msg.mtype = 1;
|
||||
strncpy(msg.mtext, pathName.toLatin1().data(), PMUPP_MAX_MTEXT);
|
||||
if (msgsnd(msqid, &msg, strlen(msg.mtext)+1, flags) == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't send the IPC message.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't send the IPC message (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
@@ -470,7 +471,7 @@ void PmuppGui::aboutToQuit()
|
||||
msqid = msgget(key, flags | S_IRUSR | S_IWUSR);
|
||||
if (msqid != -1) {
|
||||
if (msgctl(msqid, IPC_RMID, NULL) == -1) {
|
||||
std::cerr << "**ERROR** couldn't removed the message queue (msqid=" << msqid << ")." << std::endl << std::endl;
|
||||
std::cerr << "**ERROR** couldn't removed the message queue (msqid=" << msqid << ", " << std::strerror(errno) << ")." << std::endl << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2185,7 +2186,7 @@ void PmuppGui::plot()
|
||||
|
||||
key = ftok(QCoreApplication::applicationFilePath().toLatin1().data(), fMuppInstance);
|
||||
if (key == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't obtain necessary key to install the IPC message queue.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't obtain necessary key to install the IPC message queue (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2195,7 +2196,7 @@ void PmuppGui::plot()
|
||||
// open the message queue
|
||||
msqid = msgget(key, flags | S_IRUSR | S_IWUSR);
|
||||
if (msqid == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't open the IPC message queue.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't open the IPC message queue (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2204,7 +2205,7 @@ void PmuppGui::plot()
|
||||
msg.mtype = 1;
|
||||
strncpy(msg.mtext, pathName.toLatin1().data(), PMUPP_MAX_MTEXT);
|
||||
if (msgsnd(msqid, &msg, strlen(msg.mtext)+1, flags) == -1) {
|
||||
QMessageBox::critical(this, "ERROR", "Couldn't send the IPC message.");
|
||||
QMessageBox::critical(this, "ERROR", QString("Couldn't send the IPC message (%1).").arg(std::strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user