Changeset 49439 in vbox for trunk/src/VBox
- Timestamp:
- Nov 11, 2013 3:30:42 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 90546
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp
r49397 r49439 559 559 } 560 560 561 const char *ctrlProcessWaitResultToText(ProcessWaitResult_T enmWaitResult) 562 { 563 switch (enmWaitResult) 564 { 565 case ProcessWaitResult_Start: 566 return "started"; 567 case ProcessWaitResult_Terminate: 568 return "terminated"; 569 case ProcessWaitResult_Status: 570 return "status changed"; 571 case ProcessWaitResult_Error: 572 return "error"; 573 case ProcessWaitResult_Timeout: 574 return "timed out"; 575 case ProcessWaitResult_StdIn: 576 return "stdin ready"; 577 case ProcessWaitResult_StdOut: 578 return "data on stdout"; 579 case ProcessWaitResult_StdErr: 580 return "data on stderr"; 581 case ProcessWaitResult_WaitFlagNotSupported: 582 return "waiting flag not supported"; 583 default: 584 break; 585 } 586 return "unknown"; 587 } 588 561 589 /** 562 590 * Translates a guest session status to a human readable … … 1254 1282 { 1255 1283 if (cMsTimeout == 0) 1256 RTPrintf(" Waiting for guest process to start...\n");1284 RTPrintf("Starting guest process ...\n"); 1257 1285 else 1258 RTPrintf(" Waiting for guest process to start(within %ums)\n", cMsTimeout);1286 RTPrintf("Starting guest process (within %ums)\n", cMsTimeout); 1259 1287 } 1260 1288 … … 1267 1295 ComSafeArrayAsInParam(aEnv), 1268 1296 ComSafeArrayAsInParam(aCreateFlags), 1269 c MsTimeout,1297 ctrlExecGetRemainingTime(u64StartMS, cMsTimeout), 1270 1298 pProcess.asOutParam())); 1271 1299 1272 /** @todo does this need signal handling? there's no progress object etc etc */ 1300 /* 1301 * Explicitly wait for the guest process to be in a started 1302 * state. 1303 */ 1304 com::SafeArray<ProcessWaitForFlag_T> aWaitStartFlags; 1305 aWaitStartFlags.push_back(ProcessWaitForFlag_Start); 1306 ProcessWaitResult_T waitResult; 1307 CHECK_ERROR_BREAK(pProcess, WaitForArray(ComSafeArrayAsInParam(aWaitStartFlags), 1308 ctrlExecGetRemainingTime(u64StartMS, cMsTimeout), &waitResult)); 1309 bool fCompleted = false; 1310 1311 ULONG uPID = 0; 1312 CHECK_ERROR_BREAK(pProcess, COMGETTER(PID)(&uPID)); 1313 if (!fDetached && pCtx->fVerbose) 1314 { 1315 RTPrintf("Process '%s' (PID %RU32) started\n", 1316 strCmd.c_str(), uPID); 1317 } 1318 else if (fDetached) /** @todo Introduce a --quiet option for not printing this. */ 1319 { 1320 /* Just print plain PID to make it easier for scripts 1321 * invoking VBoxManage. */ 1322 RTPrintf("[%RU32 - Session %RU32]\n", uPID, pCtx->uSessionID); 1323 } 1273 1324 1274 1325 vrc = RTStrmSetMode(g_pStdOut, 1 /* Binary mode */, -1 /* Code set, unchanged */); … … 1280 1331 1281 1332 /* Wait for process to exit ... */ 1282 RTMSINTERVAL cMsTimeLeft = 1; 1333 RTMSINTERVAL cMsTimeLeft = 1; /* Will be calculated. */ 1283 1334 bool fReadStdOut, fReadStdErr; 1284 1335 fReadStdOut = fReadStdErr = false; 1285 1336 1286 bool fCompleted = false; 1287 while (!fCompleted && cMsTimeLeft != 0) 1337 while ( !fCompleted 1338 && !fDetached 1339 && cMsTimeLeft != 0) 1288 1340 { 1289 1341 cMsTimeLeft = ctrlExecGetRemainingTime(u64StartMS, cMsTimeout); 1290 ProcessWaitResult_T waitResult;1291 1342 CHECK_ERROR_BREAK(pProcess, WaitForArray(ComSafeArrayAsInParam(aWaitFlags), 1292 1343 cMsTimeLeft, &waitResult)); … … 1295 1346 case ProcessWaitResult_Start: 1296 1347 { 1297 ULONG uPID = 0;1298 CHECK_ERROR_BREAK(pProcess, COMGETTER(PID)(&uPID));1299 if (pCtx->fVerbose)1300 {1301 RTPrintf("Process '%s' (PID %RU32) started\n",1302 strCmd.c_str(), uPID);1303 }1304 else /** @todo Introduce a --quiet option for not printing this. */1305 {1306 /* Just print plain PID to make it easier for scripts1307 * invoking VBoxManage. */1308 RTPrintf("%RU32, session ID %RU32\n", uPID, pCtx->uSessionID);1309 }1310 1311 1348 /* We're done here if we don't want to wait for termination. */ 1312 1349 if (fDetached) … … 1322 1359 break; 1323 1360 case ProcessWaitResult_Terminate: 1324 /* Process terminated, we're done */ 1361 if (pCtx->fVerbose) 1362 RTPrintf("Process terminated\n"); 1363 /* Process terminated, we're done. */ 1325 1364 fCompleted = true; 1326 1365 break; … … 1372 1411 } /* while */ 1373 1412 1374 /* Report status back to the user. */ 1375 if ( fCompleted 1376 && !g_fGuestCtrlCanceled) 1413 if (!fDetached) 1377 1414 { 1378 ProcessStatus_T procStatus; 1379 CHECK_ERROR_BREAK(pProcess, COMGETTER(Status)(&procStatus)); 1380 if ( procStatus == ProcessStatus_TerminatedNormally 1381 || procStatus == ProcessStatus_TerminatedAbnormally 1382 || procStatus == ProcessStatus_TerminatedSignal) 1415 /* Report status back to the user. */ 1416 if ( fCompleted 1417 && !g_fGuestCtrlCanceled) 1383 1418 { 1384 LONG exitCode; 1385 CHECK_ERROR_BREAK(pProcess, COMGETTER(ExitCode)(&exitCode)); 1419 1420 { 1421 ProcessStatus_T procStatus; 1422 CHECK_ERROR_BREAK(pProcess, COMGETTER(Status)(&procStatus)); 1423 if ( procStatus == ProcessStatus_TerminatedNormally 1424 || procStatus == ProcessStatus_TerminatedAbnormally 1425 || procStatus == ProcessStatus_TerminatedSignal) 1426 { 1427 LONG exitCode; 1428 CHECK_ERROR_BREAK(pProcess, COMGETTER(ExitCode)(&exitCode)); 1429 if (pCtx->fVerbose) 1430 RTPrintf("Exit code=%u (Status=%u [%s])\n", 1431 exitCode, procStatus, ctrlProcessStatusToText(procStatus)); 1432 1433 rcExit = (RTEXITCODE)ctrlExecProcessStatusToExitCode(procStatus, exitCode); 1434 } 1435 else if (pCtx->fVerbose) 1436 RTPrintf("Process now is in status [%s]\n", ctrlProcessStatusToText(procStatus)); 1437 } 1438 } 1439 else 1440 { 1386 1441 if (pCtx->fVerbose) 1387 RTPrintf("Exit code=%u (Status=%u [%s])\n", 1388 exitCode, procStatus, ctrlProcessStatusToText(procStatus)); 1389 1390 rcExit = (RTEXITCODE)ctrlExecProcessStatusToExitCode(procStatus, exitCode); 1442 RTPrintf("Process execution aborted!\n"); 1443 1444 rcExit = (RTEXITCODE)EXITCODEEXEC_TERM_ABEND; 1391 1445 } 1392 else if (pCtx->fVerbose)1393 RTPrintf("Process now is in status [%s]\n", ctrlProcessStatusToText(procStatus));1394 1446 } 1395 else1396 {1397 if (pCtx->fVerbose)1398 RTPrintf("Process execution aborted!\n");1399 1400 rcExit = (RTEXITCODE)EXITCODEEXEC_TERM_ABEND;1401 }1402 1447 1403 1448 } while (0); … … 1408 1453 } 1409 1454 1455 /* 1456 * Decide what to do with the guest session. If we started a 1457 * detached guest process (that is, without waiting for it to exit), 1458 * don't close the guest session it is part of. 1459 */ 1410 1460 bool fCloseSession = false; 1411 1461 if (SUCCEEDED(rc))
Note:
See TracChangeset
for help on using the changeset viewer.