LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview CLI hangs and does not leave memory

Hello,

 

I experience strange problems when using labviewcli - sometimes it hangs forever and must be terminated.

So i try to spawn it as process using powershell but when I run broken build process never ends and has to be terminated.

 

 

$arg = [string]::Format(' -OperationName ExecuteBuildSpec -ProjectPath "{0}" -LabVIEWPath "{1}" -Verbosity Detailed -LogFilePath "{2}" -TargetName "{3}" -BuildSpecName "{4}"',$projectPath,$labviewPath,$logPath,$buildTarget,$buildSpecName)
        
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = "labviewcli"
    $pinfo.RedirectStandardError = $true
    $pinfo.RedirectStandardOutput = $true
    $pinfo.UseShellExecute = $false
    $pinfo.Arguments = $arg
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start() | Out-Null
    $done = $p.WaitForExit($timeoutSec*1000)

 

 

My understanding is that after build fails log is generated and process should end just like when build works

I can confirm that log is generated with fail message: ExecuteBuildSpec operation failed.

 

In current situation it will wait full timeout despite fact that build failed and labviewcli process should be long gone.

0 Kudos
Message 1 of 2
(2,151 Views)

Issue solved, it was caused by not reading redirected outputs

 

    #format labviewcli args
    $arg = [string]::Format(' -OperationName ExecuteBuildSpec -ProjectPath "{0}" -LabVIEWPath "{1}" -Verbosity Detailed -LogFilePath "{2}" -TargetName "{3}" -BuildSpecName "{4}"',$projectPath,$labviewPath,$logPath,$buildTarget,$buildSpecName)
    #setup process
    $pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = "labviewcli"
    $pinfo.RedirectStandardError = $true
    $pinfo.RedirectStandardOutput = $true
    $pinfo.UseShellExecute = $false
    $pinfo.Arguments = $arg
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start() | Out-Null
    $errTask = $p.StandardError.ReadToEndAsync()
    $outTask = $p.StandardOutput.ReadToEndAsync()
    $done = $p.WaitForExit($timeoutSec*1000)

    if ($done -eq $false)
    { 
        $p.Kill() 
        throw 'labviewcli exceeded build timeout'
    }
    else
    {   
        if($p.ExitCode -ne 0)
        {
            Write-Host 'build failed: '(Get-Content -Path $LVlogPath)
            throw 'build failed'
        }
        else{ Write-Host 'build succeeded'}
    }

 

0 Kudos
Message 2 of 2
(2,114 Views)