@JonB Thanks! That saved me a good deal of troubleshooting. It turned out the problem was a hard path to a file inside the C program which caused it to run correctly when invoked from it's native directory, but caused a segfault when called by Qt since the paths were different. The problem is completely fixed now.
However, it's probably more suitable for you to issue the whole lot as a single string passed to /bin/sh or /bin/bash with the -c argument, and let it figure the | for you., as per my example earlier.
So my command changes in this function, should I build a custom string every time and pass it in as one statement?
I always practice in terminal first
For this purpose make yourself use /bin/sh -c "sudo dd ... | md5sum" as that is what you will need. Be careful if anything in your command requires its own quoting (your current example does not), as the whole command itself is now inside quotes.
As I wrote earlier, your md5sum is not going to see the contents from the dd. Your example does not lend itself to checksumming as it uses a single dd if=... of=... which does the input & output in one go. What you want is for the output from the dd to go both to the output file and to md5sum. Here are two possibilities for you to play with:
In the first case we tee the output off to /dev/sdb2 as well as letting it through to md5sum. Simpl-ish, but you lose the ability to specify the bs= for the output to /dev/sdb2. I don't know if that matters to you.
In the second case you use "shell magic" (you'll probably have to use /bin/bash not /bin/sh, I think) to send tee's output to md5sum process as well as passing it onto a second dd to do the output. I have made it so md5sum's output goes to standard error instead of standard output.
Why do you think python (or anything else) is going to open any terminal window? And what OS are you on anyway?
For QProcess:setProgram you should have process.setProgram("python");, only. But in this case I think it's getting overridden by your process.start("python test.py"); so it doesn't matter, but it's wrong.
If you want to grab a sub-process's output, you have to handle QProcess::readyReadStandardOutput(), and in there something like QByteArray QProcess::readAllStandardOutput(), if that's what you mean by "How can I get the 'Hello' output?".
How this relates to Trying to implement thumbnail list I have no idea....
Well, actually it does work! But if bash is not running interactively, it won't read the .bashrc where the shell-variables are stored. So I did the following:
sh.start("bash -i"); // the -i tell bash to run interactively
sh.write("printenv JAVA_HOME"); // or sh.write("echo $JAVA_HOME")
In case you were wondering, I connected the QProcess::finished signal to a slot where the QProcess::readAllStandardOutput is put in a QPlainTextEdit.
The QProcess::processEnvironment is not updated however. Even if I try to export JAVA_HOME with sh.write("export JAVA_HOME"). While that is not what I expected, I now can find the local shell-variables.
I don't need Qt for this. But I have a quite large application that does a lot of things. One of those, is to launch external applications and send them keystrokes as you would type in front of a keyboard.
Of course you should always be careful with sudoers, but even more so when using wildcards.
That's good advice and only to throw my 2 cents in:
Allowing users to change system-wide settings somehow defeats the whole point of having users in the first place. What happens if one user changes the timezone, but another is not happy with that and changes it back? These are system changes we're talking about, so that's one good reason for actually having a super user that manages them ...
Thanks for your response. The whole body of code is proprietary so I'm not sure I can share it in a public forum.
However I can make a note that it used to work fine a month ago and after that no changes occurred to this code and no qt libraries were replaced, so the issue is like to be caused by hardware malfunction.
Such a strong word ... it depends on the advisory locking mechanism used and most linux-es will support more than one. As duly noted in the documentation it's only guaranteed to work if the same scheme is used across all processes:
Serialization is only guaranteed if all processes that access the shared resource use QLockFile, with the same file path.
Does seem implementing the startDetached() is the better option ( if i understand correctly) as when the app closes , closing down the started sup processes could be problematic.
On a side note:
Needing to keep the instance around is also an interesting complexity, if logic serves,
The app starts a process (perhaps stored in a QList Or QHash)
Maintain the state so when the sup-process terminates i can ether re-use the process or remove the process and create another instance .
*with the understanding that if the main app closes all sup-process's will close.
Is the logic sound?
Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.