Commit f9e4c022 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Deal with random LD_LIBRARY_PATH additions from matlab.

Attempt to strip matlab related paths from LD_LIBRARY_PATH.
Any path containing matlab is now stripped.


git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@9480 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 2e60cd23
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ function [ check, seqs ] = cvc_check( object )
    waitbar(.10,box,'Running Proof');
%tic
    % run the cvc command
[status, result] = system(['cvc3 ' filename ' +model']);
[status, result] = safe_execute_external_command(['cvc3 ' filename ' +model']);
%toc
% check return status for errors
if (status ~= 0)
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ elseif (exists == 0 || strcmp(button,'Attempt to prove'))
    % call pvs in batch mode with script
    % ADD check that pvs actually exists in system
    %
    [status, result] = system(['pvs -batch -v 3 -l ' function_name '.el']);
    [status, result] = safe_execute_external_command(['pvs -batch -v 3 -l ' function_name '.el']);
    %toc
    %objectect.msgbox_scroll(result);
    waitbar(.70,box,'Parsing Results');
+36 −0
Original line number Diff line number Diff line
function [ status, results ] = safe_execute_external_command( cmd )
%SAFE_EXECUTE_EXTERNAL_COMMAND Executes a command avoiding various Matlab pitfalls
%   Exectues the given command using the system function, while avoid
%   various pitfalls that occur while running the matlab context.
%   Specifically, it removes matlab related paths from the LB_LIBRARY_PATH.
%   It restores them on exit.

    old_path = getenv('LD_LIBRARY_PATH');
    new_path = old_path;
    
    new_path = regexp(new_path, ':', 'split');
    new_new_path = '';
    
    for i=1:size(new_path, 2)
        finds = strfind(new_path(i), 'matlab');
        if size(finds{1}) == [0 0]
            new_new_path = [new_new_path new_path{i} ':']; %#ok<AGROW> Since size is dynamically found
        end
    end
    
    setenv('LD_LIBRARY_PATH', new_new_path(1:size(new_new_path,2)-1))
    
    had_error = 0;
    try
        [ status, results ] = system( cmd );
    catch exception
        had_error = 1;
    end
    
    setenv('LD_LIBRARY_PATH', old_path);

    if had_error == 1
        throw(exception)
    end
end