Fix issues
This commit is contained in:
parent
e8535cd25a
commit
36da65b45e
5 changed files with 30 additions and 7 deletions
|
@ -19,4 +19,23 @@
|
||||||
|
|
||||||
package de.staropensource.engine.base.platform
|
package de.staropensource.engine.base.platform
|
||||||
|
|
||||||
expect fun platformTerminate(exitcode: UByte)
|
/**
|
||||||
|
* Terminates the platform.
|
||||||
|
*
|
||||||
|
* @since v1-alpha10
|
||||||
|
*/
|
||||||
|
internal expect fun platformTerminate(exitcode: UByte)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the time in milliseconds.
|
||||||
|
*
|
||||||
|
* Should only be used for
|
||||||
|
* comparing time intervals.
|
||||||
|
* **Should not be stored as
|
||||||
|
* this method may return a
|
||||||
|
* timestamp from platform
|
||||||
|
* to platform.**
|
||||||
|
*
|
||||||
|
* @since v1-alpha10
|
||||||
|
*/
|
||||||
|
internal expect fun platformMilliseconds(): ULong
|
||||||
|
|
|
@ -37,8 +37,10 @@ abstract class ProcessPlatform (
|
||||||
/**
|
/**
|
||||||
* Initializes the process.
|
* Initializes the process.
|
||||||
*
|
*
|
||||||
|
* @throws Throwable on error
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
|
@Throws(Throwable::class)
|
||||||
abstract fun start()
|
abstract fun start()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,6 +22,7 @@ package de.staropensource.engine.base.utility
|
||||||
import de.staropensource.engine.base.type.environment.GraphicsCard
|
import de.staropensource.engine.base.type.environment.GraphicsCard
|
||||||
import de.staropensource.engine.base.type.environment.OperatingSystem
|
import de.staropensource.engine.base.type.environment.OperatingSystem
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.Instant
|
||||||
|
import kotlin.jvm.JvmStatic
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information about the
|
* Provides information about the
|
||||||
|
|
|
@ -27,8 +27,8 @@ import de.staropensource.engine.base.implementable.stream.ReadStream
|
||||||
import de.staropensource.engine.base.implementable.stream.Stream
|
import de.staropensource.engine.base.implementable.stream.Stream
|
||||||
import de.staropensource.engine.base.implementable.stream.WriteStream
|
import de.staropensource.engine.base.implementable.stream.WriteStream
|
||||||
import de.staropensource.engine.base.platform.ProcessPlatform
|
import de.staropensource.engine.base.platform.ProcessPlatform
|
||||||
|
import de.staropensource.engine.base.platform.platformMilliseconds
|
||||||
import de.staropensource.engine.base.platform.platformProcessCreate
|
import de.staropensource.engine.base.platform.platformProcessCreate
|
||||||
import java.io.IOException
|
|
||||||
import kotlin.Throws
|
import kotlin.Throws
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,7 +161,7 @@ class Process : PlatformData {
|
||||||
// Set properties
|
// Set properties
|
||||||
this.executable = executable
|
this.executable = executable
|
||||||
this.arguments = arguments
|
this.arguments = arguments
|
||||||
this.workingDirectory = workingDirectory ?: FileAccess(System.getProperty("user.dir"))
|
this.workingDirectory = workingDirectory ?: FileAccess.temporaryCacheDirectory!!
|
||||||
this.launchedWithFreshEnvironment = freshEnvironment
|
this.launchedWithFreshEnvironment = freshEnvironment
|
||||||
this.environmentVariables = environmentVariables.toMap()
|
this.environmentVariables = environmentVariables.toMap()
|
||||||
this.exitEvents = exitEvents.toMutableList()
|
this.exitEvents = exitEvents.toMutableList()
|
||||||
|
@ -184,8 +184,8 @@ class Process : PlatformData {
|
||||||
standardOutput.watch()
|
standardOutput.watch()
|
||||||
standardError.watch()
|
standardError.watch()
|
||||||
}
|
}
|
||||||
} catch (exception: IOException) {
|
} catch (throwable: Throwable) {
|
||||||
throw IOAccessException("Unable to spawn new process", exception)
|
throw IOAccessException("Unable to spawn new process", throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,9 +269,9 @@ class Process : PlatformData {
|
||||||
* @since v1-alpha10
|
* @since v1-alpha10
|
||||||
*/
|
*/
|
||||||
fun waitForExit(maxTime: ULong = 0UL): Process {
|
fun waitForExit(maxTime: ULong = 0UL): Process {
|
||||||
val maxTimeReal: Long = System.currentTimeMillis().plus(maxTime.toLong())
|
val maxTimeReal: ULong = platformMilliseconds()
|
||||||
|
|
||||||
while (maxTime == 0UL || System.currentTimeMillis() < maxTimeReal)
|
while (maxTime == 0UL || platformMilliseconds() < maxTimeReal)
|
||||||
if (!isAlive())
|
if (!isAlive())
|
||||||
break
|
break
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,4 @@
|
||||||
package de.staropensource.engine.base.platform
|
package de.staropensource.engine.base.platform
|
||||||
|
|
||||||
actual fun platformTerminate(exitcode: UByte) = Runtime.getRuntime().exit(exitcode.toInt())
|
actual fun platformTerminate(exitcode: UByte) = Runtime.getRuntime().exit(exitcode.toInt())
|
||||||
|
actual fun platformMilliseconds(): ULong = System.currentTimeMillis().toULong()
|
||||||
|
|
Loading…
Reference in a new issue