Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Calling lscm.bat from a build script causes a hang

When calling lscm.bat from Hudson, Ant script, or other build tool is causing a hang where the build never terminates. However if I change the build tool to use scm.exe the hang disappears. Why does this happen?

1 vote


Accepted answer

Permanent link
Caution should be used when using lscm.bat from a build script. The lscm.bat will start a daemon process if one is not already running on the system, and some build scripts will consider that daemon to be a child process. The build script will then wait for the daemon to terminate which will cause the build to hang up. The purpose of the lscm.bat is to load the scm tools only once and then reference it for future calls. If you are only calling a couple commands then it would be easier to just call scm.exe which does not create a daemon. However if you are going to use lots of scm commands you should start and stop the daemon process explicitly via scm daemon start and scm daemon stop respectively. That should keep the build scripts from waiting for the daemon to terminate.

When calling lscm.bat from Hudson, Ant script, or other build tool is causing a hang where the build never terminates. However if I change the build tool to use scm.exe the hang disappears. Why does this happen?
Spencer Murata selected this answer as the correct answer

3 votes

Comments

Even after I issue scm daemon start /share/root and background the process, subsequent lscm requests start another daemon, which I cannot control (running on Linux).

Why does lscm not use the scm that is already running?

Two instances that this could happen...
a) Certain commands such as help, version or remote commands such as "list workspace" does not use the sandbox. In those cases, if you ran lscm from a non-sandbox directory it will launch a new daemon. But if you run the commands from within the sandbox directory it will reuse the daemon that tracks that sandbox.
b) lscm uses one daemon to track per sandbox. So if you now loaded or operated in a second sandbox then you would see two daemon processes.

 Spencer,

I am writing some java code to get snapshot name during our builds in BF.  The scm command works fine on our Linux boxes, but on windows it hangs.. forever.  I have tried scm, lscm, starting a daemon manually.  Nothing seems to work, what else can I try to allow the command to run inside a jar successfully on windows?

Is that using the SCM binary to run the command or the API? 

We are using the scm binary, the API wasn't as straight forward. Here is a code snippet:

String command = "\"" + commandPath + File.separator + "lscm.bat"+"\""+" list snapshots -r " + repoAddress
+ " -u " + user + " -P " + "Password" + " -j " + workspaceUUID;
System.out.println("Using the following command:" + command);

Process proc = rt.exec(command);
BufferedReader br = new BufferedReader(isr);.
Do I need to include the start/stop daemon in the call>?

It would be safer to start and stop it in the script, but if you don't mind the daemon hanging around after the script runs and whatever build tool you are using to execute doesn't consider the daemon to be part of the build, i.e. it will allow the script to be marked complete, then you run without the start/stop calls.


~Spencer 

showing 5 of 6 show 1 more comments

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 1,201
× 562

Question asked: May 24 '12, 3:16 p.m.

Question was seen: 6,019 times

Last updated: Apr 07 '14, 5:14 p.m.

Confirmation Cancel Confirm