linux:
- fix: if there is a Red Panda C++ process running program, other Red Panda C++ processes can't run program correctly.
This commit is contained in:
parent
c67e196e72
commit
14d99711f8
|
@ -250,8 +250,8 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
|||
}
|
||||
#else
|
||||
QString newArguments;
|
||||
QString sharedMemoryId = "/r"+QUuid::createUuid().toString(QUuid::StringFormat::Id128);
|
||||
if (consoleFlag!=0) {
|
||||
QString sharedMemoryId = QUuid::createUuid().toString();
|
||||
QString consolePauserPath=includeTrailingPathDelimiter(pSettings->dirs().appLibexecDir())+"consolepauser";
|
||||
if (!fileExists(consolePauserPath)) {
|
||||
QMessageBox::critical(pMainWindow,
|
||||
|
@ -280,6 +280,7 @@ void CompilerManager::run(const QString &filename, const QString &arguments, con
|
|||
.arg(localizePath(filename)).arg(arguments);
|
||||
}
|
||||
execRunner = new ExecutableRunner(pSettings->environment().terminalPath(),newArguments,workDir);
|
||||
execRunner->setShareMemoryId(sharedMemoryId);
|
||||
#endif
|
||||
execRunner->setStartConsole(true);
|
||||
} else {
|
||||
|
|
|
@ -156,7 +156,7 @@ void ExecutableRunner::run()
|
|||
#elif defined(Q_OS_LINUX)
|
||||
int BUF_SIZE=1024;
|
||||
char* pBuf=nullptr;
|
||||
int fd_shm = shm_open("/REDPANDAIDECONSOLEPAUSER20211223",O_RDWR | O_CREAT,S_IRWXU);
|
||||
int fd_shm = shm_open(mShareMemoryId.toLocal8Bit().data(),O_RDWR | O_CREAT,S_IRWXU);
|
||||
if (fd_shm==-1) {
|
||||
qDebug()<<QString("shm open failed %1:%2").arg(errno).arg(strerror(errno));
|
||||
} else {
|
||||
|
@ -220,7 +220,7 @@ void ExecutableRunner::run()
|
|||
pBuf = nullptr;
|
||||
}
|
||||
if (fd_shm!=-1) {
|
||||
shm_unlink("/REDPANDAIDECONSOLEPAUSER20211223");
|
||||
shm_unlink(mShareMemoryId.toLocal8Bit().data());
|
||||
fd_shm = -1;
|
||||
}
|
||||
#endif
|
||||
|
@ -242,7 +242,7 @@ void ExecutableRunner::run()
|
|||
munmap(pBuf,BUF_SIZE);
|
||||
}
|
||||
if (fd_shm!=-1) {
|
||||
shm_unlink("/REDPANDAIDECONSOLEPAUSER20211223");
|
||||
shm_unlink(mShareMemoryId.toLocal8Bit().data());
|
||||
}
|
||||
#endif
|
||||
if (errorOccurred) {
|
||||
|
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -54,11 +54,11 @@ vector<string> GetCommand(int argc,char** argv,bool &reInp,bool &pauseAfterExit)
|
|||
int flags = atoi(argv[1]);
|
||||
reInp = flags & RPF_REDIRECT_INPUT;
|
||||
pauseAfterExit = flags & RPF_PAUSE_CONSOLE;
|
||||
for(int i = 2;i < argc;i++) {
|
||||
for(int i = 3;i < argc;i++) {
|
||||
//result += string("\"") + string(argv[i]) + string("\"");
|
||||
std::string s(argv[i]);
|
||||
|
||||
if (i==2 || (reInp && i==3 ))
|
||||
if (i==3 || (reInp && i==4 ))
|
||||
if (s.length()>2 && s[0]=='\"' && s[s.length()-1]=='\"') {
|
||||
s = s.substr(1,s.length()-2);
|
||||
}
|
||||
|
@ -130,17 +130,18 @@ int ExecuteCommand(vector<string>& command,bool reInp) {
|
|||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
char* sharedMemoryId;
|
||||
// First make sure we aren't going to read nonexistent arrays
|
||||
if(argc < 3) {
|
||||
if(argc < 4) {
|
||||
printf("\n--------------------------------");
|
||||
printf("\nUsage: ConsolePauser.exe <0|1> <filename> <parameters>\n");
|
||||
printf("\nUsage: ConsolePauser.exe <0|1> <shared_memory_id> <filename> <parameters>\n");
|
||||
printf("\n 1 means the STDIN is redirected by Red Panda C++; 0 means not\n");
|
||||
PauseExit(EXIT_SUCCESS,false);
|
||||
}
|
||||
|
||||
// Make us look like the paused program
|
||||
//SetConsoleTitleA(argv[2]);
|
||||
//SetConsoleTitleA(argv[3]);
|
||||
sharedMemoryId = argv[2];
|
||||
|
||||
bool reInp;
|
||||
bool pauseAfterExit;
|
||||
|
@ -155,18 +156,18 @@ int main(int argc, char** argv) {
|
|||
|
||||
int BUF_SIZE=1024;
|
||||
char* pBuf=nullptr;
|
||||
int fd_shm = shm_open("/REDPANDAIDECONSOLEPAUSER20211223",O_RDWR,S_IRWXU);
|
||||
int fd_shm = shm_open(sharedMemoryId,O_RDWR,S_IRWXU);
|
||||
if (fd_shm==-1) {
|
||||
//todo: handle error
|
||||
printf("shm open failed %d:%s",errno,strerror(errno));
|
||||
printf("shm open failed %d:%s\n",errno,strerror(errno));
|
||||
} else {
|
||||
if (ftruncate(fd_shm,BUF_SIZE)==-1){
|
||||
printf("ftruncate failed %d:%s",errno,strerror(errno));
|
||||
printf("ftruncate failed %d:%s\n",errno,strerror(errno));
|
||||
//todo: set size error
|
||||
} else {
|
||||
pBuf = (char*)mmap(NULL,BUF_SIZE,PROT_READ | PROT_WRITE, MAP_SHARED, fd_shm,0);
|
||||
if (pBuf == MAP_FAILED) {
|
||||
printf("mmap failed %d:%s",errno,strerror(errno));
|
||||
printf("mmap failed %d:%s\n",errno,strerror(errno));
|
||||
pBuf = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +190,7 @@ int main(int argc, char** argv) {
|
|||
munmap(pBuf,BUF_SIZE);
|
||||
}
|
||||
if (fd_shm!=-1) {
|
||||
shm_unlink("/REDPANDAIDECONSOLEPAUSER20211223");
|
||||
shm_unlink(sharedMemoryId);
|
||||
}
|
||||
|
||||
// Done? Print return value of executed program
|
||||
|
|
Loading…
Reference in New Issue