Solved posix_spawn, returns 1
-
@SPlatten Then please check what https://doc.qt.io/qt-5/qprocess.html#error and https://doc.qt.io/qt-5/qiodevice.html#errorString return
-
@jsulm , I've modified the function:
bool clsMainWnd::blnLaunch(QString strApp, QStringList& slstArgs, qint64& int64PID) { Q_ASSERT_X(clsMainWnd::mspobjProcess!=nullptr, "blnLaunch", "mspobjProcess is null!"); int intLastSep = strApp.lastIndexOf(QDir::separator()); int64PID = 0; if ( intLastSep > 0 ) { QString strName = strApp.mid(intLastSep + 1) ,strPath = strApp.mid(0, intLastSep + 1); if ( mspobjProcess->startDetached(strName, slstArgs, strPath, &int64PID) == true && int64PID > 0 ) { return true; } qDebug() << mspobjProcess->error(); } return false; }
The result is:
QProcess::UnknownError
Not terribly helpful.
-
@SPlatten said in posix_spawn, returns 1:
strName
What does it contain when you call startDetached? Did you try with absolute path to the executable?
-
@jsulm strName contains:
mdFileIO
I just tried calling the function with the absolute path:
bool clsMainWnd::blnLaunch(QString strApp, QStringList& slstArgs, qint64& int64PID) { Q_ASSERT_X(clsMainWnd::mspobjProcess!=nullptr, "blnLaunch", "mspobjProcess is null!"); int intLastSep = strApp.lastIndexOf(QDir::separator()); int64PID = 0; if ( intLastSep > 0 ) { QString strName = strApp.mid(intLastSep + 1) ,strPath = strApp.mid(0, intLastSep + 1); if ( mspobjProcess->startDetached(strApp, slstArgs, strPath, &int64PID) == true && int64PID > 0 ) { return true; } qDebug() << mspobjProcess->error(); } return false; }
Where strApp contains:
~/XMLMPAM/config/modules/mdFileIO
Same result.
-
@SPlatten said in posix_spawn, returns 1:
~/XMLMPAM/config/modules/mdFileIO
Try with whole path, without ~ as ~ is resolved by the shell as far as I know.
-
@jsulm , still having problems:
bool clsMainWnd::blnLaunch(QString strApp, QStringList& slstArgs, qint64& int64PID) { Q_ASSERT_X(clsMainWnd::mspobjProcess!=nullptr, "blnLaunch", "mspobjProcess is null!"); QString strUserProfile("~"); if ( strApp.contains(strUserProfile) == true ) { //Application path contains user proflie reference, replace with actual folder QString strUserFolder(clsDebugService::strGetUserFolder(strUserProfile)); if ( strUserFolder.endsWith(QDir::separator()) == true ) { strUserFolder = strUserFolder.left(strUserFolder.length() - 1); } strApp = strApp.replace(strUserProfile, strUserFolder); } int intLastSep = strApp.lastIndexOf(QDir::separator()); int64PID = 0; if ( intLastSep > 0 ) { QString strName = strApp.mid(intLastSep + 1) ,strPath = strApp.mid(0, intLastSep + 1); if ( mspobjProcess->startDetached(strApp, slstArgs, strPath, &int64PID) == true && int64PID > 0 ) { return true; } qDebug() << mspobjProcess->error(); } return false; }
After replacing "~" strApp now contains:
"/Users/simonplatten/XMLMPAM/config/modules/mdFileIO"
Although I get exactly the same results.
QProcess::UnknownError
[Edit] I just copied the path and app name and pasted into a terminal, I get:
Last login: Mon Sep 28 09:04:18 on ttys001 You have new mail. simonplatten@Simons-iMac ~ % /Users/simonplatten/XMLMPAM/config/modules/mdFileIO zsh: operation not permitted: /Users/simonplatten/XMLMPAM/config/modules/mdFileIO
-
@SPlatten
What is your question? If you cannot execute/Users/simonplatten/XMLMPAM/config/modules/mdFileIO
, e.g. fromzsh
, then you cannot execute it, and QtQProcess
won't solve that.From what very little I know (I'm not Mac), have you tried Googling for
zsh: operation not permitted
? You get hits telling you why this happens under various MacOS incarnations and what you are supposed to do about it to allow it to run. [Looks like it's some Mac addition for "security" purposes.] -
@JonB , I will look into it, thank you...its very odd, I am an Amin on the system.
-
@JonB ,@jsulm , got it I think, the application created by Qt Creator is not actually a file, but instead a folder:
drwxr-xr-x 3 simonplatten staff 96 28 Sep 07:29 mdFileIO.app
If I then go into this folder the actual executable is located in:
/Users/simonplatten/build-mdFileIO-Desktop_Qt_5_14_2_clang_64bit-Release/mdFileIO.app/Contents/MacOS/mdFileIO
ls -l:
-rwxr-xr-x 1 simonplatten staff 81280 28 Sep 07:29 mdFileIO
I can run this application.
-
-
It makes 0 sense to me, I've put it back exactly the way it was, in fact all I did was undo until it was as it was...rebuilt and now it works!