Hi, I have a script that starts an external process on Unity.
It runs as expected, but calling process.Kill() has no effect. The external app isn’t being terminated.
public void InitSensor ()
{
sensorStatus = SensorStatus.Initializing;
pSensor = new System.Diagnostics.Process();
pSensor.StartInfo.FileName = Application.streamingAssetsPath + "/MyApp.app";
pSensor.StartInfo.CreateNoWindow = false;
pSensor.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
pSensor.EnableRaisingEvents = true;
pSensor.Exited += OnSensorTerminated;
pSensor.Start();
sensorStatus = SensorStatus.Running;
}
public void KillSensor()
{
Debug.Log("Killing Sensor...");
if (pSensor != null)
{
pSensor.Exited -= OnSensorTerminated;
try
{
pSensor.Kill();
}
catch (Exception e)
{
Debug.LogWarning(e);
}
finally
{
pSensor.Close();
pSensor = null;
sensorStatus = SensorStatus.Exited;
}
}
}
The code is as above. Am I missing something??