-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Processes spawned by NonBlockingProcess inherit file descriptors #70
Comments
Here's a complete example for Scala (uses the package example
import com.sun.jna.{ Native, NativeLibrary }
import java.nio.file.{ Files, NoSuchFileException, Paths }
object Hello extends App {
Native.register(NativeLibrary.getProcess());
@native def close(fd: Int): Int
@native def getpid(): Int
def closeInheritedFds(): Unit = {
val pid = getpid()
try {
val dirStream = Files.newDirectoryStream(Paths.get(s"/proc/$pid/fd", "\\d*"))
try {
dirStream.forEach { path =>
val fd = path.getFileName.toString.toInt
if (fd > 2) close(fd) // Don't close stdin/stderr/stdout (> 2)
}
} finally {
dirStream.close()
}
} catch {
case _: NoSuchFileException =>
}
}
closeInheritedFds()
} |
According to the referenced NuProcess issue, this was fixed in NuProcess 1.2 and this project is now using 1.24. |
It was fixed in 7ca1ec0 but it has not yet been released. |
@2m Thanks for the update. BTW - I think that this project is a good candidate for inclusion in alpakka. |
Is there any chance to move this project to akka organizations ? |
@dpennell @hepin1989 I think we want to eventually phase out this library and move individual pieces either into Akka, Alpakka, or 'personal' repositories of maintainers outside of the Akka organization. Probably best to create issues about individual pieces in the respective repositories. I'll add a note to the README. |
@raboof - My comment was only about the process package. I'll open a ticket in the Alpakka project. |
On Linux, processes spawned by
NonBlockingProcess
inherit the JVM's open file descriptors. The underlying cause it due to this NuProcess issue.The following can be used as a work-around -- spawn
bash
to run these commands, and thenexec
the command you wished to spawn:The text was updated successfully, but these errors were encountered: