2 package org
.de
.metux
.proc
;
4 import org
.de
.metux
.util
.Exec
;
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
23 public boolean signal(String sig
)
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
));
48 public String
getHostname()
50 return new Exec().run_catch("hostname").trim();
53 public int[] getPIDs()
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
++)
65 int a
= Integer
.parseInt(entries
[x
],10);
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
++)
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();