commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rusi Filipov (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (EXEC-65) Watchdog can't destroy 'sudo' and 'sleep'
Date Sun, 25 Mar 2012 18:29:25 GMT
Watchdog can't destroy 'sudo' and 'sleep'
-----------------------------------------

                 Key: EXEC-65
                 URL: https://issues.apache.org/jira/browse/EXEC-65
             Project: Commons Exec
          Issue Type: Bug
    Affects Versions: 1.1
         Environment: RedHat Enterprise Linux 64bit, JDK 1.6.0_25 64bit.

{code}
$ uname -a
Linux demo-vrs1-happdb1.lts.stgt.vrs.cust.disy.net 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17
EDT 2006 i686 i686 i386 GNU/Linux
{code}

{code}
$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Server VM (build 20.0-b11, mixed mode)
{code}
            Reporter: Rusi Filipov
            Priority: Critical


I want to run a command from a shell script with and make sure the process will be destroyed
after a fixed timeout, especially if it asks for user input or has sleep commands inside.

{code:title=Java}
DefaultExecutor executor = new DefaultExecutor();
executor.setStreamHandler(new PumpStreamHandler(System.out, System.err));
ExecuteWatchdog watchDog = new ExecuteWatchdog(3000);
executor.setWatchdog(watchDog);
CommandLine command = new CommandLine("./client.sh");
int exitValue = executor.execute(command);
System.out.println(exitValue);
{code}

I run this code on the server like this:
{code}
java -cp .:commons-exec-1.1.jar App
{code}

*Problem 1.* I want to run {{sudo}} in order to execute a script as a different user:
{code:title=client.sh}
#!/bin/bash
sudo -u occ02 /apps/occ02/catalina_base/bin/restart-occ.sh
{code}
In case of a misconfiguration of {{/etc/sudoers}} this prompts me for a password.
{code}
Password:
{code}
And terminates only after about 5 minutes, not 3 seconds:
{code}
Exception in thread "main" org.apache.commons.exec.ExecuteException: Process exited with an
error: 143 (Exit value: 143)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
        at App.destroy2(App.java:51)
        at App.main(App.java:21)
{code}
Only if I use the {{-S}} option the process is killed after about 4 seconds:
{code}
Password:
Exception in thread "main" org.apache.commons.exec.ExecuteException: Process exited with an
error: 1 (Exit value: 1)
        at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:160)
        at org.apache.commons.exec.DefaultExecutor.execute(DefaultExecutor.java:147)
        at App.destroy2(App.java:51)
        at App.main(App.java:21)
{code}

*Problem 2.* I want to prevent a too long {{sleep}}:
{code:title=client.sh}
#!/bin/bash
sleep 900
{code}
The Process is not destroyed!

These issues are currently blocking us to use commons-exec in production. The problems were
not visible when I tested on my development machine with Windows 7 64bit and JDK 1.6.0_25,
64bit. 

Btw, with the {{ProcessBuilder}} from the JDK the process is destroyed in both cases:
{code}
ProcessBuilder builder = new ProcessBuilder("./client.sh");
Process process = builder.start();
Thread.sleep(3000);
process.destroy();
{code}

Best regards,
Rusi

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message