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.

Bug 76173 - No automatic flush of output before input
Summary: No automatic flush of output before input
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Egor Ushakov
URL:
Keywords:
: 82439 (view as bug list)
Depends on: 82439
Blocks: 142774 144106
  Show dependency tree
 
Reported: 2006-05-10 18:44 UTC by _ gordonp
Modified: 2008-08-15 18:17 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gordonp 2006-05-10 18:44:20 UTC
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)
Comment 1 _ gordonp 2006-08-11 01:20:59 UTC
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.
Comment 2 _ gordonp 2006-10-24 21:07:47 UTC
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. 
Comment 3 _ gordonp 2007-05-30 17:57:52 UTC
This issue depends on an issue which was fixed in 6.0m10. It cannot
be fixed in grgich_hills.
Comment 4 Thomas Preisler 2007-10-03 22:13:39 UTC
*** Issue 82439 has been marked as a duplicate of this issue. ***
Comment 5 Thomas Preisler 2007-10-09 00:52:57 UTC
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.
Comment 6 Thomas Preisler 2007-10-18 22:06:30 UTC
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.
Comment 7 dnikitin 2007-11-02 16:11:13 UTC
Verified in build 200711020000
Comment 8 alexandrov 2008-08-04 11:19:30 UTC
the example in description still have the same output(reading input before writing "prompt")
Comment 9 Sergey Grinev 2008-08-06 10:45:56 UTC
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
Comment 10 Sergey Grinev 2008-08-06 12:08:00 UTC
Eclipse has the same issue (version 3.3)
Comment 11 Sergey Grinev 2008-08-06 12:08:37 UTC
*** Issue 142774 has been marked as a duplicate of this issue. ***
Comment 12 Alexander Pepin 2008-08-06 15:19:01 UTC
This issue has a valuable impact on distributed development as OutputWindow is the only possibility to show project output.
Comment 13 Egor Ushakov 2008-08-08 10:30:09 UTC
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.
Comment 14 Sergey Grinev 2008-08-11 14:37:58 UTC
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.
Comment 15 Egor Ushakov 2008-08-11 15:22:35 UTC
preliminary fix for Solaris implemented in:
http://hg.netbeans.org/main/rev/26f7dbe1f5f2
Comment 16 Egor Ushakov 2008-08-14 18:51:03 UTC
fixed in the changeset:
http://hg.netbeans.org/main/rev/561ffa1a3c03
Comment 17 Egor Ushakov 2008-08-15 12:11:34 UTC
please check on all platforms, it looks like this solution does not work on windows
Comment 18 Egor Ushakov 2008-08-15 18:17:04 UTC
The solution really does not work on windows,
I created P3 issue 144106 for it separately