1010import java .util .Random ;
1111
1212import com .devkev .devscript .nativecommands .NativeLibrary ;
13- import com .devkev .devscript .raw .ProcessUtils .ExitCodes ;
13+ import com .devkev .devscript .raw .ExecutionState .ExitCodes ;
1414
1515public class Process {
1616
@@ -29,12 +29,11 @@ public class Process {
2929
3030 Block main ;
3131 //Main block is not never in the list, since the process gets terminated, if main is killed.
32- //private final ArrayList<Block> aliveBlocks = new ArrayList<Block>(1);
3332 boolean breakRequested = false ;
3433
3534 public long maxRuntime = 0 ; //Runtime in ms. If < 0, allowed runtime is infinite
3635 private long currentChar = 0 ;
37- public final String version = "1.9.12 " ;
36+ public final String version = "1.9.13 " ;
3837
3938 private boolean caseSensitive = false ;
4039
@@ -545,10 +544,10 @@ public ArrayList<Object> interpretArguments(StringBuilder command, int start, bo
545544 /**@param garbageCollector - If the process should remove variables after the block was executed.
546545 * Usually true, because the variables would not be accessible anymore anyway.
547546 * @param isConstructor - If the block is used as a constructor. This means, that variables created in this block are:
548- * not garbegage collected and are isolated from other blocks.*/
547+ * not garbegage collected and are isolated from other blocks.
548+ * @return The execution state wether this block executed successful or with an exception*/
549549 public void executeBlock (Block block , boolean garbageCollector , Object ... args ) {
550550 if (block == null ) block = getMain ();
551- //if(block.alive) kill(block, "Block already running");
552551
553552 /*The arguments are just variables declared in the block - local scope and removed afterwards, if requested*/
554553 if (block != null ) {
@@ -664,18 +663,24 @@ public synchronized void kill(Block block, String errorMessage) {
664663
665664 finalizeExit (1 , errorMessage );
666665
667- /*for(int i = 0; i < aliveBlocks.size(); i++) {
668- aliveBlocks.get(i).cached.clear();
669- aliveBlocks.get(i).alive = false;
670- aliveBlocks.get(i).interrupted = true;
671- }*/
672666 block .alive = false ;
673667 block .interrupted = true ;
674668 block .currentCommand = "" ;
675669 }
676670
671+ try {
672+ //Notify the stream, in case an input is still awaited and fire the
673+ synchronized (inputStream ) {
674+ inputStream .notify ();
675+ }
676+
677+ inputStream .close ();
678+
679+ } catch (IOException e ) {
680+ e .printStackTrace ();
681+ }
682+
677683 block .exitCode = ExitCodes .ERROR ;
678- //aliveBlocks.clear();
679684 garbageCollection (main );
680685 }
681686
0 commit comments