KtSh
KtSh copied to clipboard
Subprocess spawned from inside shell does not stop when shell.interrupt() or shell.shutdown() is called.
I am running a python script using shell.run()
But even after interrupt() or even shutdown(), the subprocess spawned inside the python script still keeps running.
val result = shell.run(command)
Timber.d("Exit Code ${result.exitCode}") //Correctly receives non zero exit code.
Is this an issue with signal forwarding or am I doing anything wrong?
init {
main.viewModelScope.launch {
main.eventFlow.collect{
when(it){
is ViewModelEvent.CancelProcess -> {
CoroutineScope(Dispatchers.IO).launch {
//Event is fired
shell.interrupt()
}
}
else -> {}
}
}
}
}
shell = Shell("/path/to/sh")
fun runCommandForShareWithEnv(command: String){
CoroutineScope(Dispatchers.IO).launch{
val result = shell.run(command)
Timber.d("Exit Code ${result.exitCode}") //Correctly receives non zero exit code.
}
}
This is for a FOSS project. https://github.com/cryptrr/AutoPie