imported from svn
[metux-java.git] / proc / System_LinuxLocal.java
blob3b1882e1686ebb68a94f953ea8636b809d05e822
2 package org.de.metux.proc;
4 import org.de.metux.util.Exec;
5 import java.io.File;
6 import java.lang.NumberFormatException;
8 /* hmm. seems this code only works w/ kaffe/classpath :( */
10 public class System_LinuxLocal implements ISystem
12 public static final String proc_prefix = "/proc/";
14 private class ProcInf implements IProcess
16 int pid;
17 ProcInf(int my_pid)
19 pid = 0;
20 this.pid = my_pid;
23 public boolean signal(String sig)
25 if (sig==null)
26 throw new NullPointerException("parameter SIGNAL is NULL");
28 for (int x=0; x<valid_signals.length; x++)
30 if (sig.equals(valid_signals[x]))
32 System.err.println("GOT valid signame: "+sig);
33 System.err.println("OUT="+
34 new Exec().run_catch("kill -"+sig+" "+pid));
38 return false;
42 public int getPID()
44 return pid;
48 public String getHostname()
50 return new Exec().run_catch("hostname").trim();
53 public int[] getPIDs()
55 int sz = 0;
56 File f = new File (proc_prefix);
57 String entries[] = f.list();
59 // pids in ints umwandeln. fixme: evtl. noch auf dir checken
60 int [] pids = new int[entries.length];
61 for (int x=0; x<entries.length; x++)
63 try
65 int a = Integer.parseInt(entries[x],10);
66 pids[sz++] = a;
68 catch (NumberFormatException e)
73 // compress the array, so that the length is the actual
74 // number of processes. leave no gaps.
75 int [] pids2 = new int[sz];
76 for (int x=0; x<sz; x++)
77 pids2[x] = pids[x];
79 return pids2;
82 public IProcess getProcess(int pid)
85 // not finished yet :(
86 // File handle = new File(proc_prefix+pid+"/");
87 // Process_LinuxLocal process = new Process_LinuxLocal();
90 return null;