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 165982 - IDE terminates when "reused" console is closed
Summary: IDE terminates when "reused" console is closed
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Launchers&CLI (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P1 blocker (vote)
Assignee: t_h
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-25 16:37 UTC by Jiri Sedlacek
Modified: 2013-04-17 13:05 UTC (History)
2 users (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 Jiri Sedlacek 2009-05-25 16:37:20 UTC
On Windows I'm starting the IDE from the Command Prompt using 'start netbeans.exe'. When invoked help for the start
command 'start /?' it "Starts a separate window to run a specified program or command". In Windows this typically means
that a new process independent on the parent console is started.

In 6.7, the IDE reuses the parent console for its output: "The launcher has determined that the parent process has a
console and will reuse it for its own console output." However, there is no mention about immediately terminating the
IDE when the console is closed - in fact depending on the console process. This actually causes several serious problems

 1/ The 'start' command should start a separate process independent on the parent console. The IDE changes the intended
OS behavior and breaks the 'start' command logic. When Enter is pressed in the console, it shows a standard command
prompt and there's no indication that the console controls the IDE.

 2/ The message logged into the console just mentions sharing the output. There's no warning that the IDE will
immediately terminate when the console is closed.

 3/ When the user closes the parent console, the IDE terminates immediately without persisting any unsaved data, which
leads to unexpected data loss - this is not an artificial case, it unfortunately happened to me.
Comment 1 Jiri Sedlacek 2009-05-25 16:37:41 UTC
I think the correct fix should be not breaking the 'start' command logic - parent console shouldn't be reused by the IDE
when started using the 'start' command. If not safely fixable for 6.7 I think there should be a clear warning logged
into the parent console that closing it will immediately terminate the IDE without saving any data.
Comment 2 Jiri Sedlacek 2009-05-25 16:39:49 UTC
Could be treated as P1 - regression (used to work correctly in 6.5) and data loss (user may lose unsaved work by closing
the console).

Fortunately, there's an easy workaround by changing the default console-reusing behavior:

Use '--console suppress' to suppress console output.
Use '--console new' to create a separate console window.
Comment 3 t_h 2009-05-27 15:04:19 UTC
In 6.7 during Win NB launcher rewrite it was decided to join netbeans.exe/nb.exe to single executable netbeans.exe. The
idea was that netbeans.exe should behave as console application if started from console and as window application
otherwise. Therefore, netbeans.exe by default attaches itself to parent console (if exists) and use it in similar way as
nb.exe did (and is terminated as nb.exe was if console is closed). However, there are some limitations (caused by the
fact that netbeans.exe is not console application) which cannot be overcome. Additional command line parameters were
introduced to be sure all possible use cases are covered.

1) start command creates separate console only for console application which is not case of netbeans.exe.
2) OK, this information will be added.
3) It is the same case as closing console for nb.exe.

If you want the exact behavior of old nb.exe (block console it is invoked from, open another console if called by start)
you can create nb.bat containing "start /WAIT netbeans.exe %1 %2 %3 %4 %5 %6 %7 %8 %9"
Comment 4 t_h 2009-05-27 15:07:22 UTC
core-main #ecda0e155b45
Comment 5 Jiri Sedlacek 2009-05-27 15:12:04 UTC
I'm not sure if the console is really a parent console when the IDE has been started using the 'start' command. I think
it's an independent process not related to the IDE.

Another problem is that if you press Enter in the console it displays the command prompt and accepts other commands. Any
further commands are then messed-up by the IDE output - is it possible to block the console when reused by the IDE?
Comment 6 t_h 2009-05-27 15:21:23 UTC
If you run 'start' command from console, the console is parent process of new started process.

As I already wrote, console can be blocked with the help of start command :) 'start /WAIT netbeans.exe'
Comment 7 t_h 2009-05-27 15:26:10 UTC
If you meant if it is possible to block console from within netbeans executable then answer is NO.
Comment 8 Quality Engineering 2009-05-28 08:43:59 UTC
Integrated into 'main-golden', will be available in build *200905280201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ecda0e155b45
User: Tomas Holy <t_h@netbeans.org>
Log: #165982: Adding warning to 'attach console' message
Comment 9 Quality Engineering 2009-05-29 08:25:22 UTC
Integrated into 'main-golden', will be available in build *200905290201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/31c9af08adba
User: Tomas Holy <t_h@netbeans.org>
Log: #165982: message tuning
Comment 10 Antonin Nebuzelsky 2009-06-01 12:46:18 UTC
Looks good. Please integrate in release67.
Comment 11 t_h 2009-06-01 13:08:37 UTC
Integrated to release clone http://hg.netbeans.org/release67/rev/c186587c79f3
Comment 12 matusdekanek 2009-06-17 10:48:35 UTC
the warning is there, marking verified.
however, it would be really nice, if the IDE behaves normally on the command line - this is not the first issue where 
the program behaves strangely on the commandline because it 'is not console application'.