if you attempt to run a dos batch file that has an "exit" command within it then the task does not notice that the interpreter has terminated.

      e.g. in workflow create a CPS with the following

      node {
            bat '''echo hello
      exit 1'''
            echo 'should not be seen'
      }
      

      This results in a workflow that will run forever.

          [JENKINS-27419] dos "exit" command not functioning correctly

          James Nord created issue -

          Daniel Beck added a comment -

          Isn't that what the /b flag is for?

          Daniel Beck added a comment - Isn't that what the /b flag is for?

          James Nord added a comment -

          well that depends on your perspective.

          There is no other cmd.exe interpreter in the view of the user - so they would logically assume that the script is run with cmd.exe /k the_contents_of_the_stuff.

          regardless of that, the end result is not good - having a task running that has died looks bad for Jenkins and gives the impression of a Jenkins issue even if it is PEBKAC.

          James Nord added a comment - well that depends on your perspective. There is no other cmd.exe interpreter in the view of the user - so they would logically assume that the script is run with cmd.exe /k the_contents_of_the_stuff. regardless of that, the end result is not good - having a task running that has died looks bad for Jenkins and gives the impression of a Jenkins issue even if it is PEBKAC.
          Jesse Glick made changes -
          Component/s Original: workflow-plugin [ 18820 ]
          Labels New: workflow

          Jesse Glick added a comment -

          Since I have no idea what /b or /k do I am passing back to you!

          Jesse Glick added a comment - Since I have no idea what /b or /k do I am passing back to you!
          Jesse Glick made changes -
          Assignee Original: Jesse Glick [ jglick ] New: James Nord [ teilo ]

          James Nord added a comment -
          cmd.exe /?
              Starts a new instance of the Windows command interpreter
              /K      Carries out the command specified by string but remains
          
          > help exit
          Quits the CMD.EXE program (command interpreter) or the current batch
          script.
          
          EXIT [/B] [exitCode]
            /B          specifies to exit the current batch script instead of
                        CMD.EXE.  If executed from outside a batch script, it
                        will quit CMD.EXE
          

          basically if you forget to add /b to your dos script (e.g. if you want to terminate early using exit) you will kill the cmd.exe process and Jenkins will sit until the end of days and not realize...

          James Nord added a comment - cmd.exe /? Starts a new instance of the Windows command interpreter /K Carries out the command specified by string but remains > help exit Quits the CMD.EXE program (command interpreter) or the current batch script. EXIT [/B] [exitCode] /B specifies to exit the current batch script instead of CMD.EXE. If executed from outside a batch script, it will quit CMD.EXE basically if you forget to add /b to your dos script (e.g. if you want to terminate early using exit) you will kill the cmd.exe process and Jenkins will sit until the end of days and not realize...
          James Nord made changes -
          Assignee Original: James Nord [ teilo ] New: Jesse Glick [ jglick ]
          Jesse Glick made changes -
          Link New: This issue is related to JENKINS-28759 [ JENKINS-28759 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]

            jglick Jesse Glick
            teilo James Nord
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: