summaryrefslogtreecommitdiff
path: root/openEMS/matlab/queue_checkProcess.m
blob: 878165ad77b8d878697bb81883d83915fd31ab78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function [alive,stdout,stderr] = queue_checkProcess( pid, filenames )
% [alive,stdout,stderr] = queue_checkProcess( pid )
%
% Sebastian Held <sebastian.held@uni-due.de>
% 12.5.2010

if ~isunix
    error 'your OS is not supported (Unix only)'
end

if nargout > 1
    fid = fopen( filenames.stdout );
    stdout = fread(fid, '*char')';
    fclose(fid);
end
if nargout > 2
    fid = fopen( filenames.stderr );
    stderr = fread(fid, '*char')';
    fclose(fid);
end

cmd = ['ps --no-headers -p' num2str(pid) ];
[status,~] = unix( cmd );

alive = (status == 0);