diff --git a/src/com/sheepit/client/Client.java b/src/com/sheepit/client/Client.java index 4ef0d4e..1b498be 100644 --- a/src/com/sheepit/client/Client.java +++ b/src/com/sheepit/client/Client.java @@ -35,6 +35,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.Date; +import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -522,6 +524,10 @@ public class Client { String[] command = new String[size_command]; + Map new_env = new HashMap(); + + new_env.put("BLENDER_USER_CONFIG", this.config.workingDirectory.getAbsolutePath().replace("\\", "\\\\")); + int index = 0; for (int i = 0; i < command1.length; i++) { if (command1[i].equals(".c")) { @@ -580,7 +586,7 @@ public class Client { String line; this.log.debug(Arrays.toString(command)); OS os = OS.getOS(); - ajob.setProcess(os.exec(command)); + ajob.setProcess(os.exec(command, new_env)); BufferedReader input = new BufferedReader(new InputStreamReader(ajob.getProcess().getInputStream())); long last_update_status = 0; diff --git a/src/com/sheepit/client/os/Linux.java b/src/com/sheepit/client/os/Linux.java index dff2c44..a6843d9 100644 --- a/src/com/sheepit/client/os/Linux.java +++ b/src/com/sheepit/client/os/Linux.java @@ -122,7 +122,7 @@ public class Linux extends OS { } @Override - public Process exec(String[] command) throws IOException { + public Process exec(String[] command, Map env_overight) throws IOException { // the renderer have a lib directory so add to the LD_LIBRARY_PATH // (even if we are not sure that it is the renderer who is launch @@ -155,6 +155,9 @@ public class Linux extends OS { builder.redirectErrorStream(true); Map env = builder.environment(); env.putAll(new_env); + if (env_overight != null) { + env.putAll(env_overight); + } return builder.start(); } diff --git a/src/com/sheepit/client/os/Mac.java b/src/com/sheepit/client/os/Mac.java index ac8ca87..b59f5be 100644 --- a/src/com/sheepit/client/os/Mac.java +++ b/src/com/sheepit/client/os/Mac.java @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.util.Map; import com.sheepit.client.Log; import com.sheepit.client.Utils; @@ -140,7 +141,7 @@ public class Mac extends OS { } @Override - public Process exec(String[] command) throws IOException { + public Process exec(String[] command, Map env) throws IOException { String[] actual_command = command; if (this.hasNiceBinary == null) { this.checkNiceAvailability(); @@ -154,6 +155,9 @@ public class Mac extends OS { } ProcessBuilder builder = new ProcessBuilder(actual_command); builder.redirectErrorStream(true); + if (env != null) { + builder.environment().putAll(env); + } return builder.start(); } diff --git a/src/com/sheepit/client/os/OS.java b/src/com/sheepit/client/os/OS.java index 748cc70..e7687bb 100644 --- a/src/com/sheepit/client/os/OS.java +++ b/src/com/sheepit/client/os/OS.java @@ -19,6 +19,7 @@ package com.sheepit.client.os; import java.io.IOException; +import java.util.Map; import com.sheepit.client.hardware.cpu.CPU; @@ -37,9 +38,12 @@ public abstract class OS { return null; } - public Process exec(String[] command) throws IOException { + public Process exec(String[] command, Map env) throws IOException { ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); + if (env != null) { + builder.environment().putAll(env); + } return builder.start(); } diff --git a/src/com/sheepit/client/os/Windows.java b/src/com/sheepit/client/os/Windows.java index 779438a..9e04b0e 100644 --- a/src/com/sheepit/client/os/Windows.java +++ b/src/com/sheepit/client/os/Windows.java @@ -19,6 +19,7 @@ package com.sheepit.client.os; import java.io.IOException; +import java.util.Map; import com.sheepit.client.hardware.cpu.CPU; import com.sheepit.client.os.windows.Kernel32Lib; @@ -106,7 +107,7 @@ public class Windows extends OS { } @Override - public Process exec(String[] command) throws IOException { + public Process exec(String[] command, Map env) throws IOException { // disable a popup because the renderer might crash (seg fault) Kernel32Lib kernel32lib = null; try { @@ -125,6 +126,9 @@ public class Windows extends OS { ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); + if (env != null) { + builder.environment().putAll(env); + } Process p = builder.start(); WinProcess wproc = new WinProcess(p); wproc.setPriority(WinProcess.PRIORITY_BELOW_NORMAL);