This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
In C/C++ programs the OS (I believe all OS') flushes stdout before a read from stdin. This isn't happening in cnd. As a result, the following code reads input before displaying the output: #include <stdio.h> int main(int argc, char **argv) { char *cp, buf[BUFSIZ]; printf("prompt: "); cp = gets(buf); } Outputs: asdf prompt: (the "asdf" is the echo of what I typed into the input textfield)
I've duplicated the problem in pure Java. We'll use a different output tab type which supports both input and output (with the input inline). See IZ 82439.
Downgrading to P3 and removing CND1-FCS flag. The cnd1 resolution of this problem is being done in 86984. This issue is for a more permanent solution and is blocked by 82439 which won't get fixed until 6.0. So this issue cannot be fixed in cnd1.
This issue depends on an issue which was fixed in 6.0m10. It cannot be fixed in grgich_hills.
*** Issue 82439 has been marked as a duplicate of this issue. ***
NB's fix of 84375 doesn't seem to help. 82439 depends on 84375. 84375 may not have been completely fixed or CND. See 84375 for details.
Using io.getOut() directly and not PrintWriter(new OutputWindowWriter(io.getOut()... for execution seems to do the trick. We don't need error parsing for execution - just for building.
Verified in build 200711020000
the example in description still have the same output(reading input before writing "prompt")
Problem seems to be in the buffering of the output of runned process. E.g. printed by std::cout data is shown correctly, because of no buffering. But using printf() will not help. Example 1 - this code wouldn't appear till the user input: main() { printf("prompt:"); char c = getchar(); } but Example 2 - this code works perfectly: main() { cout << "prompt:"; char c; cin >> c; } and Example 3 - next code samples being run will be shown normally in Output window: main() { setvbuf(stdout, NULL, _IONBF, 0); // switch off buffering printf("prompt:"); char c = getchar(); } main() { printf("prompt:"); std::cout.flush(); char c = getchar(); } Reassigned for investigation
Eclipse has the same issue (version 3.3)
*** Issue 142774 has been marked as a duplicate of this issue. ***
This issue has a valuable impact on distributed development as OutputWindow is the only possibility to show project output.
The solution is to use GdbHelper.so for run in output window as we does for debugging. It does turn on line buffering for output stream.
I think after fixing this issue we should set "Output Window" as default Console type for Run action in project properties. And remove "(output only)" note from it.
preliminary fix for Solaris implemented in: http://hg.netbeans.org/main/rev/26f7dbe1f5f2
fixed in the changeset: http://hg.netbeans.org/main/rev/561ffa1a3c03
please check on all platforms, it looks like this solution does not work on windows
The solution really does not work on windows, I created P3 issue 144106 for it separately