You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "David Hawkins (JIRA)" <ji...@codehaus.org> on 2005/11/20 19:51:06 UTC

[jira] Created: (MNG-1632) mvn.bat does not properly return the exit code of the java process

mvn.bat does not properly return the exit code of the java process
------------------------------------------------------------------

         Key: MNG-1632
         URL: http://jira.codehaus.org/browse/MNG-1632
     Project: Maven 2
        Type: Bug
  Components: maven-release-plugin, maven-core  
    Reporter: David Hawkins


This manifests itself when running release:perform and an error occurs in the child process.  The stdout shows a build error for the child process, but a shows build success for the outer process.  This is pretty confusing if you only happen to look at the last message.
This patch also makes mvn.bat return the error code properly to when running within cygwin. 

Detailed explanation: The problem is that running mvn.bat within cygwin, you are actually running cmd.exe which then executes mvn.bat.  The exit code returned to the calling application is actually the exit code from the execution of cmd.exe, not the .bat script executed within it.  In order to get the exit code all the way out to the calling application, you have to omit the /b when calling exit. ("exit 0" vs. "exit /b 0").  When calling exit without the /b, the cmd prompt window (if any) will actually exit, so mvn.bat makes sure it is a batch script whose execution originated in a cygwin shell.  If it originated in cygwin, it uses "exit" else it uses "exit /b".


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Updated: (MNG-1632) mvn.bat does not properly return the exit code of the java process

Posted by "David Hawkins (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-1632?page=all ]

David Hawkins updated MNG-1632:
-------------------------------

    Attachment: MNG-1632-maven-core-2.patch

Sorry for taking so long to respond on this.

I have created a new patch, "MNG-1632-maven-core-2.patch", which handles the MAVEN_TERMINATE_CMD environment variable. If the variable is set to anything other than "", mvn.bat will terminate cmd rather than exit /b.  I've verified this works correctly by calling it with a test java application and calling it within cygwin. I have not tested it with continuum.

--David


> mvn.bat does not properly return the exit code of the java process
> ------------------------------------------------------------------
>
>          Key: MNG-1632
>          URL: http://jira.codehaus.org/browse/MNG-1632
>      Project: Maven 2
>         Type: Bug
>   Components: maven-release-plugin, Plugins and Lifecycle
>     Reporter: David Hawkins
>  Attachments: MNG-1632-maven-core-2.patch, MNG-1632-maven-core.patch
>
>
> This manifests itself when running release:perform and an error occurs in the child process.  The stdout shows a build error for the child process, but a shows build success for the outer process.  This is pretty confusing if you only happen to look at the last message.
> This patch also makes mvn.bat return the error code properly to when running within cygwin. 
> Detailed explanation: The problem is that running mvn.bat within cygwin, you are actually running cmd.exe which then executes mvn.bat.  The exit code returned to the calling application is actually the exit code from the execution of cmd.exe, not the .bat script executed within it.  In order to get the exit code all the way out to the calling application, you have to omit the /b when calling exit. ("exit 0" vs. "exit /b 0").  When calling exit without the /b, the cmd prompt window (if any) will actually exit, so mvn.bat makes sure it is a batch script whose execution originated in a cygwin shell.  If it originated in cygwin, it uses "exit" else it uses "exit /b".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Updated: (MNG-1632) mvn.bat does not properly return the exit code of the java process

Posted by "David Hawkins (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNG-1632?page=all ]

David Hawkins updated MNG-1632:
-------------------------------

    Attachment: MNG-1632-maven-core.patch

> mvn.bat does not properly return the exit code of the java process
> ------------------------------------------------------------------
>
>          Key: MNG-1632
>          URL: http://jira.codehaus.org/browse/MNG-1632
>      Project: Maven 2
>         Type: Bug
>   Components: maven-release-plugin, maven-core
>     Reporter: David Hawkins
>  Attachments: MNG-1632-maven-core.patch
>
>
> This manifests itself when running release:perform and an error occurs in the child process.  The stdout shows a build error for the child process, but a shows build success for the outer process.  This is pretty confusing if you only happen to look at the last message.
> This patch also makes mvn.bat return the error code properly to when running within cygwin. 
> Detailed explanation: The problem is that running mvn.bat within cygwin, you are actually running cmd.exe which then executes mvn.bat.  The exit code returned to the calling application is actually the exit code from the execution of cmd.exe, not the .bat script executed within it.  In order to get the exit code all the way out to the calling application, you have to omit the /b when calling exit. ("exit 0" vs. "exit /b 0").  When calling exit without the /b, the cmd prompt window (if any) will actually exit, so mvn.bat makes sure it is a batch script whose execution originated in a cygwin shell.  If it originated in cygwin, it uses "exit" else it uses "exit /b".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Commented: (MNG-1632) mvn.bat does not properly return the exit code of the java process

Posted by "Emmanuel Venisse (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNG-1632?page=comments#action_51980 ] 

Emmanuel Venisse commented on MNG-1632:
---------------------------------------

Can you add a test on %MAVEN_TERMINATE_CMD%? if it's true, you must exit without /B
We need it when we run mvn from a java process.

> mvn.bat does not properly return the exit code of the java process
> ------------------------------------------------------------------
>
>          Key: MNG-1632
>          URL: http://jira.codehaus.org/browse/MNG-1632
>      Project: Maven 2
>         Type: Bug
>   Components: maven-release-plugin, Plugins and Lifecycle
>     Reporter: David Hawkins
>  Attachments: MNG-1632-maven-core.patch
>
>
> This manifests itself when running release:perform and an error occurs in the child process.  The stdout shows a build error for the child process, but a shows build success for the outer process.  This is pretty confusing if you only happen to look at the last message.
> This patch also makes mvn.bat return the error code properly to when running within cygwin. 
> Detailed explanation: The problem is that running mvn.bat within cygwin, you are actually running cmd.exe which then executes mvn.bat.  The exit code returned to the calling application is actually the exit code from the execution of cmd.exe, not the .bat script executed within it.  In order to get the exit code all the way out to the calling application, you have to omit the /b when calling exit. ("exit 0" vs. "exit /b 0").  When calling exit without the /b, the cmd prompt window (if any) will actually exit, so mvn.bat makes sure it is a batch script whose execution originated in a cygwin shell.  If it originated in cygwin, it uses "exit" else it uses "exit /b".

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org