Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-22992

wait_for_pid() function in shell_utils_launcher.cpp doesn't wait for program output to finish being consumed

    • Fully Compatible
    • ALL
    • v3.2
    • Hide
      (function() {
          var lineContents = "a\n";
          var numLines = 1000;
      
          // run('echo', ...) will produce 'numLines' of output and block until the program exits.
          var exitCode = run("echo", lineContents.repeat(numLines));
          var output = rawMongoProgramOutput();
      
          assert.eq(0, exitCode);
      
          // The program runner includes an extra trailing newline in the output.
          assert.eq(numLines, output.split(lineContents).length - 1,
                    "didn't wait for program's output buffer to finish being consumed");
      })();
      
      Show
      ( function () { var lineContents = "a\n" ; var numLines = 1000; // run( 'echo' , ...) will produce 'numLines' of output and block until the program exits. var exitCode = run( "echo" , lineContents.repeat(numLines)); var output = rawMongoProgramOutput(); assert.eq(0, exitCode); // The program runner includes an extra trailing newline in the output. assert.eq(numLines, output.split(lineContents).length - 1, "didn 't wait for program' s output buffer to finish being consumed" ); })();
    • Platforms 18 (08/05/16), Platforms 2016-08-26, Platforms 2016-09-19, Platforms 2016-10-10, Platforms 2016-10-31
    • 27

      Some tests rely on being able to call _runMongoProgram() or _stopMongoProgram() and then make assertions about the program's output using rawMongoProgramOutput(). However, while the process may have exited, the code does not wait for all of the program's output to have been consumed from the pipe and for ProgramOutputMultiplexer::appendLine() to have been called on it.

      BSONObj RunMongoProgram(const BSONObj& a, void* data) {
          ProgramRunner r(a);
          r.start();
          stdx::thread t(r);
          t.detach();
          int exit_code = -123456;  // sentinel value
          wait_for_pid(r.pid(), true, &exit_code);
          registry.deleteProgram(r.pid());
          return BSON(string("") << exit_code);
      }
      

            Assignee:
            matt.cotter Matt Cotter
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: