Disclaimer: I didn't use this... so i might be wrong, but
as far as i know the '\n' line end doesn't flush the stream, try to use std::endl to finish the line.
Disclaimer: I didn't use this... so i might be wrong, but
as far as i know the '\n' line end doesn't flush the stream, try to use std::endl to finish the line.
In C you can use:
to flush the stdout bufferQt Code:
printf(...); fflush(stdout);To copy to clipboard, switch view to plain text mode
No, don't use that in Qt.
Use that in your C application (if you have the source of the C application)
If you run your C program from a dos command line, do you get all output?
Well, you can always give root access to your program permanently, if you don't want to request it whilst running:
chown root your_app
chmod a+xs your_app
@Wysota: You are right, the actual flush is "done" by the OS, but "when" is done can be controlled from your code, and the new-line character '\n' doesn't "force" the OS to flush the output stream, while the endl does.
@Raul: your problem is within the C application
i don't think that you can force the stream to flush from QProcess (i might be wrong) maybe you can wait for the C application to finnish (that must cause a flush) and then see what you have in that byte-array (again i don't know if QProcess still "capture" the flush if it is closing the other process)
I don't know if this is the case in all basic operating systems but at least in Unices the default buffering for streams is "line buffering", so \n has to force a flush. Anyway take a look at any decent C application and check if every printf() is followed by fflush.
You are not wrong. What one could do is to use stddup, disable buffering of the newly created stream and set that stream as stdout of the newly created process (of course you need to spawn it yourself using proper native means). At least in Unicesi don't think that you can force the stream to flush from QProcess (i might be wrong)
Anyway the "problem" is obviously in behaviour of the slave program.
@Wysota: I didn't said you are wrong, and you are right about line-buffer in *nix, but this isn't a behavior that you can assume it's true (especially if you want multi-platform)
Correct again, it is highly not recommended to force flush on every printf()/cout, because the OS "usually" does a good job and flush the buffer whenever necessary, but this isn't a standard cross-platform "thing" (in some situations you can have different behaviors on same platform), so in some cases like the one we are talking wright now it is (or should be) necessary to "force" the flush.Anyway take a look at any decent C application and check if every printf() is followed by fflush.
Check out PAM.
What would also be interesting is that if you open a file as binary, you don't (or at least, I would expect you didn't) get flushing on newline. Do you get fliushing on endl even though the file is binary? I know using endl on a binary file is a bit strange, but it would be interesting to find out. Unless of course endl on a binary file causes a run time error?
[QUOTE=fatjuicymole;146411]Check out PAM.
what the "PAM" reffers to?
Bookmarks