Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

2
Task/Fork/J/fork.j Normal file
View file

@ -0,0 +1,2 @@
load'dll'
Fork =: (('Error'"_)`('Parent'"_)`)(@.([: >: [: * '/lib/x86_64-linux-gnu/libc-2.19.so __fork > x' cd [: i. 0&[))

View file

@ -0,0 +1,4 @@
(let (pid (fork (println "Hello from child")))
(cond
((nil? pid) (throw-error "Unable to fork"))
('t (wait-pid pid))))

View file

@ -0,0 +1,16 @@
import java.io.IOException
object Fork extends App {
val builder: ProcessBuilder = new ProcessBuilder()
val currentUser: String = builder.environment.get("USER")
val command: java.util.List[String] = java.util.Arrays.asList("ps", "-f", "-U", currentUser)
builder.command(command)
try {
val lines = scala.io.Source.fromInputStream(builder.start.getInputStream).getLines()
println(s"Output of running $command is:")
while (lines.hasNext) println(lines.next())
}
catch {
case iox: IOException => iox.printStackTrace()
}
}

View file

@ -0,0 +1,14 @@
import java.io.IOException
object Fork extends App {
val command: java.util.List[String] = java.util.Arrays.asList("cmd.exe", "/C", "ECHO.| TIME")
val builder: ProcessBuilder = new ProcessBuilder(command)
try {
val lines = scala.io.Source.fromInputStream(builder.start.getInputStream).getLines()
println(s"Output of running $command is:")
while (lines.hasNext) println(lines.next())
}
catch {
case iox: IOException => iox.printStackTrace()
}
}