MATLAB Answers

kill a processb from matlab

35 views (last 30 days)
Sajid Afaque
Sajid Afaque on 14 Jan 2020
Commented: Walter Roberson on 14 Jan 2020
hello all
i have got the process id [pid] of an external process.
what is the syntax to kill that process using the pid.
i want to kill using pid not by process name from matlab

  0 Comments

Sign in to comment.

Answers (2)

Selva Karna
Selva Karna on 14 Jan 2020
from command window enter key word : cntorl +C

  1 Comment

Walter Roberson
Walter Roberson on 14 Jan 2020
That cannot be used to kill a particular process using its PID.

Sign in to comment.


Walter Roberson
Walter Roberson on 14 Jan 2020
pid = whatever number
if ispc
cmd = sprintf('taskkill /PID %d', pid);
else
cmd = sprintf('kill %d', pid);
end
system(cmd)

  2 Comments

Sajid Afaque
Sajid Afaque on 14 Jan 2020
ERROR: The process with PID 9448 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
i am getting the above error
Walter Roberson
Walter Roberson on 14 Jan 2020
pid = whatever number
if ispc
cmd = sprintf('taskkill /F /PID %d', pid);
else
cmd = sprintf('kill %d', pid);
end
system(cmd)

Sign in to comment.

Tags