LinkClose[link]
"does not necessarily terminate the program at the other end
of the connection" as it is said in the Documentation. Is there a way to kill the
process of the slave kernel securely?
EDIT:
In really I need a function in Mathematica that returns only when the process of the slave kernel has already killed and its memory has already released. Both LinkInterrupt[link, 1]
and LinkClose[link]
do not wait while the slave kernel exits. At this moment the only such function is seemed to be killProc[procID]
function I had showed in one of answers at this page. But is there a built-in analog?
At this moment I know only one method to kill the
MathKernel
process securely. This method usesNETLink
and seems to work only under Windows and requires Microsoft .NET 2 or later to be installed.Any suggestions or improvements will be appreciated.
Edit:
The more correct method:
Edit 2:
Even more correct method:
Todd Gayley has answered my question in the newsgroup. The solution is to send to the slave kernel an
MLTerminateMessage
. From top-level code:In C:
In Java using J/Link:
In .NET using .NET/Link:
EDIT:
I have discovered that in standard cases when using
LinkInterrupt[link, 1]
my operating system (Windows 2000 at the moment) releases physical memory only in 0.05-0.1 second beginning with a moment of execution ofLinkInterrupt[link, 1]
while withLinkClose[link]
it releases physical memory in 0.01-0.03 second (both values include the time, spent on execution of the command itself). Time intervals were measured by usingSessionTime[]
under equal conditions and are steadily reproduced.Actually I need a function in Mathematica that returns only when the process of the slave kernel has already killed and its memory has already released. Both
LinkInterrupt[link, 1]
andLinkClose[link]
do not wait while the slave kernel exits. At this moment the only such function is seemed to bekillProc[procID]
function I had showed in another answer at this page.