falconboy
Posts: 2
Joined: Tue Apr 18, 2006 2:40 pm

Single Instance feature for command line mode is missing

Hi,

I bought Advanced Installer primarily because of its simple "Single Instance" mode for Java (secondaryMain). However, it does not work as advertised in command line mode!

The problems are as follows:
(1) The java launcher returns immediately, while it should wait for secondaryMain to return.
(2) Standard-in, -out, -err are still that of first, rather than second, launcher.
(3) Exit-code (return value of secondaryMain) is not returned.

This renders the "Single Instance" mode useless for command line mode, i.e., only useful when registering file extensions.

This is not as advertised!

When will you fix the above problems?

(I am aware that, for backwards-compatibilty, you may have to introduce a secondaryMainBlocking or secondaryMainCLI method -- however, on the other side, probaly nobody has been made use of this feature in CLI).

Let me add that Single Instance mode for command line tools would be extremely beneficial to boost popularity of your tool - simply because the start-up time of the JDK is that high - think of scripts and how they could become 10 times faster!

Regards,
Falk
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,
The problems are as follows:
(1) The java launcher returns immediately, while it should wait for secondaryMain to return.
(2) Standard-in, -out, -err are still that of first, rather than second, launcher.
(3) Exit-code (return value of secondaryMain) is not returned.
1. We have added this on our TODO list.
2. The second instance runs in the same virtual machine as the first one so the standard -in, -out, -err are for the first instance.
However we will study this problem and if it is possible to do we will.
3. The signature of "secondaryMain" method is:

Code: Select all

static void secondaryMain( String args[] )
so this method does not return any value.

All the best,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
falconboy
Posts: 2
Joined: Tue Apr 18, 2006 2:40 pm

gigi wrote:Hi,
The problems are as follows:
(1) The java launcher returns immediately, while it should wait for secondaryMain to return.
(2) Standard-in, -out, -err are still that of first, rather than second, launcher.
(3) Exit-code (return value of secondaryMain) is not returned.
1. We have added this on our TODO list.
This is GREAT news! Let me know when it is done, even w/o 2. and 3. :wink:
gigi wrote:2. The second instance runs in the same virtual machine as the first one so the standard -in, -out, -err are for the first instance.
However we will study this problem and if it is possible to do we will.
Well, I know this one may be hard (no fpdup in Java...). However, assuming that the first invocation executes a command and then just sits and plays a service..., then the solution is simpler:

Code: Select all

InputStream in = ...;
OutputStream out, err = ...;
System.setIn(new BufferedInputStream(in));
System.setOut(new PrintStream(new BufferedOutputStream(out, 128), true));
System.setErr(new PrintStream(new BufferedOutputStream(err, 128), true));
return secondaryMainCLI (args)
where in, out, and err are built from the std-streams of the second invocation which are passed alongside args to the first. One could use a pipe here or any means of communication between two launchers. Maybe, this behaviour should be enabled explicitely within the INI file.
gigi wrote:3. The signature of "secondaryMain" method is:

Code: Select all

static void secondaryMain( String args[] )
so this method does not return any value.
Ooops :oops: However, what i WANTED to say is: There actually should be a

Code: Select all

static int secondaryMainCLI( String args[] )
which returns the launcher's exit code -- because System.exit() cannot be used :idea:

As I said, this is essential because the whole speed-up thing is most important for scripting which needs the exit code.

As we are never returning from main (just blocking) we have no need for a

Code: Select all

static int primaryMainCLI( String args[] )

Regards,
Falk
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

Thank you for your suggestions.

All the best,
Gigi
_________________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”