File: queue_checkProcess.m

package info (click to toggle)
openems 0.0.35+dfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,288 kB
  • sloc: cpp: 40,259; yacc: 580; lex: 350; makefile: 258; sh: 169; ruby: 19
file content (25 lines) | stat: -rw-r--r-- 558 bytes parent folder | download | duplicates (2)
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);