Command Line call randomly hangs

Please post all questions on Help+Manual 8 here

Moderators: Alexander Halser, Tim Green

User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Command Line call randomly hangs

Unread post by dgaudian »

I am currently integrating Help & Manual into our automatic build process. Here I need to call the command line version with some simple parameters from a PowerShell script. Every now and then, the script will hang and the HELPMAN.EXE process does not disappear from the TaskManager. It does not happen every time but often enough to be a serious blocking point before deployment to our build server.
The same command line hangs too from time to time if started in a cmd window.

Update: Sometimes the PowerShell window will regain focus again, the helpman.exe process is no longer running, but the script still hangs

Update 2: If I wait long enough (10 minutes, 20, my lunch break) the script continues - not really suitable for a CI environment

Help & Manual Version 8.2.1 Build 5670
Windows Version 10 20H2

The script looks something like this - when hanging we never get to the Write-Host "Exit Code: $($proc.ExitCode)"

$workdir = "C:\DEV\project"
$helpdir = Join-Path $workdir "50_src\Help\En"
$helprepo = Join-Path $helpdir "repo"

$manhelp = "c:\Program Files (x86)\EC Software\HelpAndManual8\HELPMAN.EXE"
$manhelpproject = Join-Path $helprepo "project.hmxp"
$helpfile = Join-Path $workdir "_build\project.chm"
$logfile = Join-Path $workdir "project.help.log"
$skinfile = "CHM Skin, project.hmskin"
Write-Host "Starting $($manhelp) $manhelpproject ""/CHM=$($helpfile)"" ""/L=$($logfile)"" ""/O=$($skinfile)"""
$proc = Start-Process -PassThru -Wait -FilePath $manhelp -ArgumentList """$($manhelpproject)""","""/CHM=$($helpfile)""","""/L=$($logfile)""","""/O=$($skinfile)"""
Write-Host "Exit Code: $($proc.ExitCode)"
if($proc.ExitCode -ne 0)
{
Write-Host "Help Compile failed"
Exit $proc.ExitCode
}
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Command Line call randomly hangs

Unread post by Tim Green »

Hi "d",

Can you provide an echo of the command line that is actually being executed? That would be the first step to working out if you are actually creating a valid command line or not.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

Hi Tim,

the command line is
"c:\Program Files (x86)\EC Software\HelpAndManual8\HELPMAN.EXE" "C:\DEV\t1-host-sw-ii\50_src\Help\En\repo\T1.hmxp" "/CHM=C:\DEV\t1-host-sw-ii\_build\T1.chm" "/L=C:\DEV\t1-host-sw-ii\T1.help.log" "/O=CHM Skin, Gliwa.hmskin"

I've started some long running tests: The time this command line takes to execute is anywhere between 30 seconds (which is still far longer than when I simply export inside the GUI) to 45 minutes.

Kind regards,
Dirk
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

Hi Tim,
I have found a solution, but I shall burn in hell eternally for it:
If I pass all the necessary arguments to a start a cmd-file (cmd.exe /c compilehelp.cmd), it works.

It now looks like this:

# Help & Manual
$manhelp = "c:\Program Files (x86)\EC Software\HelpAndManual8\HELPMAN.EXE"
# The project to compile
$manhelpproject = Join-Path $helprepo "project.hmxp"
# The help file to create
$helpfile = Join-Path $builddir "project.chm"
# Where the log files are output to
$logfile = Join-Path $workdir "project.help.log"
# Where the log files are output to
$skinfile = "CHM Skin, project.hmskin"
# We will execute a command file instead of calling help & manual directly: It behaves strange in PowerShell
$cmdfile = Join-Path $builddir "cmd.cmd"
# Write the command file
Out-File -FilePath $cmdfile -InputObject "%1 %2 %3 %4 %5" -Encoding default
# Tell us, what is happening
Write-Host "Starting cmd.exe /c ""$($startcmd)"" ""$($manhelp)"" ""$manhelpproject"" ""/CHM=$($helpfile)"" ""/L=$($logfile)"" ""/O=$($skinfile)"""
$proc = Start-Process -PassThru -Wait -FilePath "cmd.exe" -ArgumentList
# Start the cmd.exe with the command file and the necessary argumnents
'/c',"$cmdfile","""$($manhelp)""","""$($manhelpproject)""","""/CHM=$($helpfile)""","""/L=$($logfile)""","""/O=$($skinfile)"""
# Quickly remove the command file. I don't want anybody to find it
Remove-Item $cmdfile
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Command Line call randomly hangs

Unread post by Tim Green »

If I pass all the necessary arguments to a start a cmd-file (cmd.exe /c compilehelp.cmd), it works.
I'm afraid that was what I was going to suggest as well. Help+Manual's CLI hasn't been tested in PowerShell... :oops:
I have found a solution, but I shall burn in hell eternally for it:
Nah, you're good. It would be another matter if you were using Fortran 80... :lol:
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

After using the "wrap it up in a CMD" approach for some days, I find the problem is not really solved. The time the cmd runs is not very much better and not at all deterministic - between "some dozen seconds" to "a couple of minutes".
Our build servers a configured to kill builds that exceed a certain time.
Resources are limited and builds are pipelined, but with any good CI-system, any commit to a branch will trigger a build.
So now we have half the builds failing because they were killed and the logs clearly state that they were killed during the strange hanging behaviour.
Any other ideas?
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Command Line call randomly hangs

Unread post by Tim Green »

dgaudian wrote: Fri Nov 27, 2020 9:09 am Any other ideas?
Use a CMD or BAT directly and not PowerShell. Do it at least once manually to see whether you can export without problems when you do that, or whether there is an issue in the actual commands you are executing. It's also conceivable that some resources you are accessing during the export processes are having access problems or timing out, for example.
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

Starting a Windows Command Prompt and running the command works fine
Wrapping the command in a *.cmd file from a Windows Command Prompt works fine
Wrapping the command in a *.cmd file from a Windows Command Prompt but passing the parameters to the *.cmd works fine

Starting a Windows PowerShell and running the command shows the issue
Wrapping the command in a *.cmd file and starting cmd.exe inside a Windows PowerShell shows the issue

Using an execution wrapper command line tool used in dozens of different projects before, that completely redirect stdin, stdout and stderr with the necessary parameters to call Help&Manual with command line parameters from a Windows Command Prompt works fine

Using an execution wrapper command line tool used in dozens of different projects before, that completely redirect stdin, stdout and stderr with the necessary parameters to call Help&Manual with command line parameters from a Windows PowerShell shows the issue

As soon as Help&Manual is run inside a Windows PowerShell - however well I try to wrap that - I run into this issue.
I cannot change the build process to not call Help&Manual inside a PowerShell script - even when wrapped by cmd.exe, our execution wrapper or both.

I have tried to analyse the issue a little further: It looks as if the command line parameter called Help&Manual does not simply use the compile and save functionality withing Help&Manual, but actually fires up a complete Help&Manual, hiding its User Interface and controlling the export by calling button handlers etc. and waiting for the hidden windows to close before exiting.

Anything else I can try?
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Tim Green
Site Admin
Posts: 23156
Joined: Mon Jun 24, 2002 9:11 am
Location: Bruehl, Germany
Contact:

Re: Command Line call randomly hangs

Unread post by Tim Green »

Hi "D",

Thanks a lot for the detailed information. Our developers will look into this issue. We may contact you by email to ask you for some demo files. 8)
Regards,
Tim (EC Software Documentation & User Support)

Private support:
Please do not email or PM me with private support requests -- post to the forum directly.
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

Yes, have your developers contact me if necessary. Don't hesitate to use dirk@gaudian.de too - I have very flexible office hours and tend to be away when everybody else is working ...
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Command Line call randomly hangs

Unread post by Alexander Halser »

Hi Dirk,

I tried running H&M in the Windows PowerShell today but could not find any problems. The actual command is wrapped in a .cmd or .bat file, but it certainly works with flexible parameters as well. My PowerShell opens a CMD window with black background, compiles and exits.

Code: Select all

Start-Process -Wait MyCommand.cmd
So I'm really not sure what to do about it. Do you have any examples that you could forward to us?
It looks as if the command line parameter called Help&Manual does not simply use the compile and save functionality within Help&Manual, but actually fires up a complete Help&Manual, hiding its User Interface and controlling the export by calling button handlers etc. and waiting for the hidden windows to close before exiting.
The "fires up a complete Help&Manual" is correct. But you don't see anything of the H&M UI, do you? The command line interface differs from a simple call to open a project file just slightly. Behind the scenes, even in command line mode some windows are created but not shown.

If no additional command line parameters are set after the project file parameter, H&M will run in UI mode. The only thing that could prevent H&M from compiling the project and exiting with either a success result or error would be an internal error during the compilation.

I suggest to create a publishing task within the help project (in the publish dialog), and refer to this internal publishing task from the command line. That way you can easily test the entire batch command in UI mode, see the results, then refer to the same settings on the command line. The publishing tasks dialog can save a .CMD file for reference. I just did that and called it with the code line above.
Alexander Halser
Senior Software Architect, EC Software GmbH
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

I have a working version now. The publishing task did not really help because our build system requires input and output paths that are not relative to each other. But if I don't use the /L= command line switch (no log file) or if the file name for the /O= param is a full path (not just the file name) it works fine. It is OR! So as I don't really need the log file and I can pass the skin project as full path, all is well.

If you need more details or would like to test something on my machine, feel free to contact me.

Maybe one speciality of my machine: I have some drives connected via VPN that are often disconnected and I have a lot of funny hardware attached.
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Command Line call randomly hangs

Unread post by Alexander Halser »

if the file name for the /O= param is a full path (not just the file name)
The /O= param for the skin is interpreted relative to the project file, not relative to the location where you start the batch call. If your /O filename and path doesn't contain any spaces, you can omit the quotation marks. Maybe this makes a difference?
It is OR!
This very much sounds to me as if H&M gets the wrong params and runs into an error that halts the entire batch call.
Alexander Halser
Senior Software Architect, EC Software GmbH
User avatar
dgaudian
Posts: 11
Joined: Tue Nov 17, 2020 5:29 pm

Re: Command Line call randomly hangs

Unread post by dgaudian »

Well it does compile and the output is good. But it simply hangs after the compilation for anything up to five minutes. The very same command line was ok if issued directly at the Windows Command Prompt. The trouble started when issued in a PowerShell - no matter if directly or nested in a CMD file or called by our (until now) unfailable executor. Removing either logging or expanding the skin project to a full path was the solution. I did both. I have seen many strange things in my last 30 years of Windows programming so I am willing to believe it is my solution although inexplicable ...
Dirk Gaudian - Senior Software Developer UI/UX - GLIWA embedded systems GmbH
User avatar
Alexander Halser
EC-Software Support
Posts: 4098
Joined: Mon Jun 24, 2002 7:24 pm
Location: Salzburg, Austria
Contact:

Re: Command Line call randomly hangs

Unread post by Alexander Halser »

The /O and /L params are trailing behind the output format param, aren't they? They have to.
Alexander Halser
Senior Software Architect, EC Software GmbH
Post Reply