Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
38
Task/Fork/Java/fork.java
Normal file
38
Task/Fork/Java/fork.java
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.BufferedReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class RFork {
|
||||
|
||||
public static void main(String[] args) {
|
||||
ProcessBuilder pb;
|
||||
Process pp;
|
||||
List<String> command;
|
||||
Map<String, String> env;
|
||||
BufferedReader ir;
|
||||
String currentuser;
|
||||
String line;
|
||||
try {
|
||||
command = Arrays.asList("");
|
||||
pb = new ProcessBuilder(command);
|
||||
env = pb.environment();
|
||||
currentuser = env.get("USER");
|
||||
command = Arrays.asList("ps", "-f", "-U", currentuser);
|
||||
pb.command(command);
|
||||
pp = pb.start();
|
||||
ir = new BufferedReader(new InputStreamReader(pp.getInputStream()));
|
||||
line = "Output of running " + command.toString() + " is:";
|
||||
do {
|
||||
System.out.println(line);
|
||||
} while ((line = ir.readLine()) != null);
|
||||
}
|
||||
catch (IOException iox) {
|
||||
iox.printStackTrace();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
27
Task/Fork/NetRexx/fork.netrexx
Normal file
27
Task/Fork/NetRexx/fork.netrexx
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
|
||||
runSample(arg)
|
||||
return
|
||||
|
||||
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
method runSample(arg) private static
|
||||
|
||||
do
|
||||
pb = ProcessBuilder([String ''])
|
||||
env = pb.environment()
|
||||
currentuser = String env.get('USER')
|
||||
command = Arrays.asList([String 'ps', '-f', '-U', currentuser])
|
||||
pb.command(command)
|
||||
pp = pb.start()
|
||||
ir = BufferedReader(InputStreamReader(pp.getInputStream()))
|
||||
line = String 'Output of running' command.toString() 'is:'
|
||||
loop label w_ until line = null
|
||||
say line
|
||||
line = ir.readLine()
|
||||
end w_
|
||||
catch iox = IOException
|
||||
iox.printStackTrace()
|
||||
end
|
||||
|
||||
return
|
||||
11
Task/Fork/Nimrod/fork.nimrod
Normal file
11
Task/Fork/Nimrod/fork.nimrod
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import posix
|
||||
|
||||
var pid = fork()
|
||||
if pid < 0:
|
||||
# error forking a child
|
||||
elif pid > 0:
|
||||
# parent, and pid is process id of child
|
||||
else:
|
||||
# child
|
||||
quit()
|
||||
# further Parent stuff here
|
||||
Loading…
Add table
Add a link
Reference in a new issue