Changeset 35541 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jan 13, 2011 3:41:29 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r35534 r35541 317 317 bool fWaitForStdErr = false; 318 318 bool fVerbose = false; 319 bool fTimeout = false;320 319 321 320 int vrc = VINF_SUCCESS; … … 374 373 case 't': /* Timeout */ 375 374 u32TimeoutMS = ValueUnion.u32; 376 fTimeout = true;377 375 break; 378 376 … … 461 459 if (fWaitForExit) 462 460 { 463 if ( fTimeout)461 if (u32TimeoutMS) /* Wait with a certain timeout. */ 464 462 { 465 463 /* Calculate timeout value left after process has been started. */ … … 468 466 if (u32TimeoutMS > u64Elapsed) 469 467 { 470 u32TimeoutMS -= (uint32_t)u64Elapsed;471 468 if (fVerbose) 472 RTPrintf("Waiting for process to exit (%ums left) ...\n", u32TimeoutMS );469 RTPrintf("Waiting for process to exit (%ums left) ...\n", u32TimeoutMS - u64Elapsed); 473 470 } 474 471 else … … 478 475 } 479 476 } 480 else if (fVerbose) 477 else if (fVerbose) /* Wait forever. */ 481 478 RTPrintf("Waiting for process to exit ...\n"); 482 479 … … 505 502 || fWaitForStdErr) 506 503 { 507 /** @todo r=bird: Why use u32TimeoutMS here? */508 504 rc = guest->GetProcessOutput(uPID, 0 /* aFlags */, 509 u32TimeoutMS, _64K, ComSafeArrayAsOutParam(aOutputData)); 505 RT_MAX(0, u32TimeoutMS - (RTTimeMilliTS() - u64StartMS)) /* Timeout in ms */, 506 _64K, ComSafeArrayAsOutParam(aOutputData)); 510 507 if (FAILED(rc)) 511 508 { 512 509 vrc = ctrlPrintError(guest, COM_IIDOF(IGuest)); 513 514 510 cbOutputData = 0; 515 fCompleted = true; /* rc contains a failure, so we'll go into aborted state down below. */516 511 } 517 512 else … … 541 536 } 542 537 } 543 if (cbOutputData <= 0) /* No more output data left? */ 544 { 545 if (fCompleted) 546 break; 547 548 /** @todo r=bird: Why only apply the timeout here? 549 * Shouldn't it time out regardless of 550 * whether there is more output or not? */ 551 if ( fTimeout 552 && RTTimeMilliTS() - u64StartMS > u32TimeoutMS + 5000) 553 { 554 progress->Cancel(); 555 break; 556 } 557 } 538 539 /* No more output data left? Then wait a little while ... */ 540 if (cbOutputData <= 0) 541 progress->WaitForCompletion(1 /* ms */); 558 542 559 543 /* Process async cancelation */ … … 574 558 } 575 559 576 /* Make sure the loop is not too tight. */ 577 RTThreadYield(); 560 /* Did we run out of time? */ 561 if ( u32TimeoutMS 562 && RTTimeMilliTS() - u64StartMS > u32TimeoutMS) 563 { 564 progress->Cancel(); 565 break; 566 } 578 567 } 579 568
Note:
See TracChangeset
for help on using the changeset viewer.