* The name of the process.
*/
protected String name;
+ /**
+ * The PID of the process
+ */
+ protected int pid = -1;
+ /**
+ * The PPID of the process
+ */
+ protected int ppid = -1;
+ /**
+ * The host of the process
+ */
+ protected Host host = null;
/**
*
* @return
this.args.addAll(Arrays.asList(args));
MsgNative.processCreate(this, host);
+
}
* @param process the process to be killed.
*
*/
- public static void kill(Process process) {
- process.nativeStop();
- Msg.info("Process " + process.msgName() + " will be killed.");
+ public void kill() {
+ nativeStop();
+ Msg.info("Process " + msgName() + " will be killed.");
}
- /**
- * This method adds an argument in the list of the arguments of the main function
- * of the process.
- *
- * @param arg The argument to add.
- *
- * @deprecated
- */
- @Deprecated
- protected void addArg(String arg) {
- args.add(arg);
- }
/**
* Suspends the process by suspending the task on which it was
*/
public Host getHost() {
Process.ifInterruptedStop();
- return MsgNative.processGetHost(this);
+ if (this.host == null) {
+ this.host = MsgNative.processGetHost(this);
+ }
+ return this.host;
}
/**
* This static method gets a process from a PID.
*/
public int getPID() {
Process.ifInterruptedStop();
- return MsgNative.processGetPID(this);
+ if (pid == -1) {
+ pid = MsgNative.processGetPID(this);
+ }
+ return pid;
}
/**
* This method returns the PID of the parent of a process.
*/
public int getPPID() {
Process.ifInterruptedStop();
- return MsgNative.processGetPPID(this);
+ if (ppid == -1) {
+ ppid = MsgNative.processGetPPID(this);
+ }
+ return ppid;
}
/**
* This static method returns the currently running process.
public static void migrate(Process process, Host host) {
Process.ifInterruptedStop();
MsgNative.processMigrate(process, host);
+ process.host = null;
}
/**
* Makes the current process sleep until time seconds have elapsed.