Skip to content

Commit

Permalink
improved SpawnedMatlab.terminate, killing only listeners other than S…
Browse files Browse the repository at this point in the history
….PID
  • Loading branch information
EastEriq committed Feb 6, 2024
1 parent 948a6ae commit 336816d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions +obs/+util/@SpawnedMatlab/terminate.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ function terminate(S,killlisteners)
S.Messenger.send('exit')
end

thisPID=S.PID;
% if the slave is dead/unresponsive, or send() times out, kill it
if isempty(S.Messenger.LastError)
S.PID=[];
S.Status='disconnected';
elseif ~isempty(S.PID)
elseif ~isempty(thisPID)
S.report(['graceful exit of slave session ' S.Id ...
' timed out\n'])
end
Expand All @@ -37,8 +38,11 @@ function terminate(S,killlisteners)
S.PID=[];
S.Status='disconnected';

pause(2); % tune time, give time to the session to exit
[LM,LR]=S.listeners;
if ~isempty(thisPID)
LM(LM==thisPID)=[];
LR(LR==thisPID)=[];
end
if ~isempty(LM)
S.report('there are still processes listening on udp port %d\n',...
S.Messenger.DestinationPort)
Expand Down

0 comments on commit 336816d

Please sign in to comment.