How to gracefully complete a process created with scala

I am currently using the scala API scala.sys.process, but I cannot figure out how to gracefully terminate a process that responds to a SIGTERM signal. I did this in python before there is a beautiful function in the process terminateand send_signal, but in the scala object, scala.sys.process.Processall I see is that destroy. For me it looks like this: scala will destroy my process from orbit, just to be sure, and this is not what I want.

How can I say that this process should clear itself and exit my scala code?

val launcher = Process("myprocess", Seq("args"))
val process = launcher.run()
process.destroy() //Err... no? terminate or equivalent like in python please?

EDIT

More: My scala process launches a C ++ subprocess that listens for a signal handler (SIGTERM, SIGKILL, etc.) to find out when to exit. It was well tested and properly cleaned. My problem is that I do not know how to send this signal from my scala application! Thus, my C ++ process is always pulled out and removed instead of just asking to stop.

+5
source share
1 answer

Scala Processmaterial is based on Java and therefore subject to the same limitations. Java provides a very bad interface. Perhaps this allows you to use the same interface for other systems, but it incredibly limits the work with Posix systems.

+3
source

All Articles