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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue