It's all about the answers!

Ask a question

Calling lscm.bat from a build script causes a hang


Spencer Murata (2.3k115971) | asked May 24 '12, 3:16 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
edited Jun 04 '12, 9:37 a.m.
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?

Accepted answer


permanent link
Spencer Murata (2.3k115971) | answered May 24 '12, 3:20 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
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

Comments
Bonnie Teymouri commented Jan 17 '13, 2:48 p.m.

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?


Shashikant Padur commented Jan 18 '13, 1:34 a.m.
JAZZ DEVELOPER

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.


Daniel martin commented Mar 25 '14, 11:52 a.m.

 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?


Spencer Murata commented Mar 25 '14, 11:55 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

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


Daniel martin commented Apr 07 '14, 3:39 p.m.

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>?


Spencer Murata commented Apr 07 '14, 5:14 p.m.
FORUM MODERATOR / JAZZ DEVELOPER

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 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.