File: queue_addProcess.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 (22 lines) | stat: -rw-r--r-- 525 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
function [pid,filenames] = queue_addProcess( command )
% [pid,filenames] = queue_addProcess( command )
%
% Sebastian Held <sebastian.held@uni-due.de>
% 12.5.2010

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

if nargout > 1
    filenames.stdout = tempname;
    filenames.stderr = tempname;
else
    filenames.stdout = '/dev/null';
    filenames.stderr = '/dev/null';
end

cmd = ['(' command ') >' filenames.stdout ' 2>' filenames.stderr ' & echo $!' ];
[~,result] = unix( cmd );

pid = str2double(result);