save-cli
save-cli copied to clipboard
ProcessBuilder: make `exec` suspendable
Now we have a runBlocking call inside exec, which is fine for SAVE, but makes it hard to use ProcessBuilder in save-agent inside coroutine-powered code. We should lift runBlocking higher in SAVE.
Also, possible enhancements:
- Log thread id in logger (because kotlin/native uses pthread)
logTracewhen killing a process after timeout (maybe, process hangs becausepkillis executed incorrectly and does nothing?)
One more thing to consider when using save-core in multithreaded app:
kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at kfun:kotlin.Throwable#<init>(kotlin.String?){} (0x47ad6b)
at kfun:kotlin.Exception#<init>(kotlin.String?){} (0x474647)
at kfun:kotlin.RuntimeException#<init>(kotlin.String?){} (0x474837)
at kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} (0x4a8ee7)
at ThrowIncorrectDereferenceException (0x4c4dd6)
at CheckGlobalsAccessible (0xa5f942)
at kfun:org.cqfn.save.core.logging#<get-logType>(){}org.cqfn.save.core.config.LogType (0x6f9b7e)
at kfun:org.cqfn.save.core.logging#logTrace(kotlin.String){} (0x6faa8d)
at kfun:org.cqfn.save.core.utils.ProcessBuilder#exec(kotlin.String;kotlin.String;okio.Path?;kotlin.Long){}org.cqfn.save.core.utils.ExecutionResult (0x71079c)
@sanyavertolet Need to add logging for each and every line in ProcessBuilder (with all the information)!
Need to consider news from coroutines project: https://github.com/JetBrains/kotlin/blob/master/kotlin-native/NEW_MM.md#update-the-libraries. Soon coroutines will move to the new memory model, we might try it now in save-cli or in save-agent.
Some useful links: https://github.com/pgreze/kotlin-process/blob/main/src/main/kotlin/com/github/pgreze/process/Process.kt https://discuss.kotlinlang.org/t/calling-blocking-code-in-coroutines/2368/11 https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/create-coroutine.html