View | Details | Raw Unified | Return to bug 5907
Collapse All | Expand All

(-)src/main/org/apache/tools/ant/taskdefs/ExecTask.java (+21 lines)
Lines 90-95 public class ExecTask extends Task { Link Here
90
    private boolean failIfExecFails = true;
90
    private boolean failIfExecFails = true;
91
    private String executable;
91
    private String executable;
92
    private boolean resolveExecutable = false;
92
    private boolean resolveExecutable = false;
93
    private boolean waitFor = true;
93
94
94
    private Redirector redirector = new Redirector(this);
95
    private Redirector redirector = new Redirector(this);
95
    
96
    
Lines 100-105 public class ExecTask extends Task { Link Here
100
    private boolean vmLauncher = true;
101
    private boolean vmLauncher = true;
101
102
102
    /**
103
    /**
104
     * Controls whether or not to wait for the process to finish.
105
     *
106
     * @Author Charles Hudak <CHudak@arrowheadgrp.com>
107
     */
108
    public void setWaitfor(boolean wait)
109
    {
110
        this.waitFor = wait;
111
    }    
112
113
    /**
103
     * Timeout in milliseconds after which the process will be killed.
114
     * Timeout in milliseconds after which the process will be killed.
104
     *
115
     *
105
     * @since Ant 1.5
116
     * @since Ant 1.5
Lines 388-393 public class ExecTask extends Task { Link Here
388
        exe.setAntRun(getProject());
399
        exe.setAntRun(getProject());
389
        exe.setWorkingDirectory(dir);
400
        exe.setWorkingDirectory(dir);
390
        exe.setVMLauncher(vmLauncher);
401
        exe.setVMLauncher(vmLauncher);
402
        exe.setWaitfor(this.waitFor);
403
        if(this.waitFor){
404
         
405
            log("Waiting for process to complete...", Project.MSG_INFO);
406
        }
407
        else{
408
            
409
            log("Spawning process without waiting to complete.", Project.MSG_INFO); 
410
        }
411
391
        String[] environment = env.getVariables();
412
        String[] environment = env.getVariables();
392
        if (environment != null) {
413
        if (environment != null) {
393
            for (int i = 0; i < environment.length; i++) {
414
            for (int i = 0; i < environment.length; i++) {
(-)src/main/org/apache/tools/ant/taskdefs/Execute.java (-5 / +18 lines)
Lines 91-96 public class Execute { Link Here
91
    private File workingDirectory = null;
91
    private File workingDirectory = null;
92
    private Project project = null;
92
    private Project project = null;
93
    private boolean newEnvironment = false;
93
    private boolean newEnvironment = false;
94
    private boolean waitFor = true;
94
95
95
    /** Controls whether the VM is used to launch commands, where possible */
96
    /** Controls whether the VM is used to launch commands, where possible */
96
    private boolean useVMLauncher = true;
97
    private boolean useVMLauncher = true;
Lines 474-486 public class Execute { Link Here
474
    }
475
    }
475
476
476
    protected void waitFor(Process process) {
477
    protected void waitFor(Process process) {
477
        try {
478
        if (waitFor)
478
            process.waitFor();
479
        {
479
            setExitValue(process.exitValue());
480
            try {
480
        } catch (InterruptedException e) {
481
                process.waitFor();
481
            process.destroy();
482
                setExitValue(process.exitValue());
483
            } catch (InterruptedException e) {
484
                process.destroy();
485
            }
486
        }
487
        else 
488
        {
489
            setExitValue(0);
482
        }
490
        }
483
    }
491
    }
492
493
    public void setWaitfor(boolean wait)
494
    {
495
        this.waitFor = wait;
496
    }    
484
497
485
    protected void setExitValue(int value) {
498
    protected void setExitValue(int value) {
486
        exitValue = value;
499
        exitValue = value;
(-)src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java (-3 / +3 lines)
Lines 129-147 public class PumpStreamHandler implement Link Here
129
129
130
    public void stop() {
130
    public void stop() {
131
        try {
131
        try {
132
            outputThread.join();
132
            outputThread.join(500);
133
        } catch (InterruptedException e) {
133
        } catch (InterruptedException e) {
134
            // ignore
134
            // ignore
135
        }
135
        }
136
        try {
136
        try {
137
            errorThread.join();
137
            errorThread.join(500);
138
        } catch (InterruptedException e) {
138
        } catch (InterruptedException e) {
139
            // ignore
139
            // ignore
140
        }
140
        }
141
141
142
        if (inputThread != null) {
142
        if (inputThread != null) {
143
            try {
143
            try {
144
                inputThread.join();
144
                inputThread.join(500);
145
            } catch (InterruptedException e) {
145
            } catch (InterruptedException e) {
146
                // ignore
146
                // ignore
147
            } 
147
            } 

Return to bug 5907