Stay organized with collections
Save and categorize content based on your preferences.
6. Exiting the sandbox
Depending on how you run the sandbox (see this step), you
have to adjust the way you terminate the sandbox, and thus also the Sandboxee.
Exiting a sandbox running synchronously
If the sandbox has been running synchronously, then Run will only return when
the Sandboxee is finished. Therefore no additional step for termination is
required. The code snippet below shows this scenario:
Sandbox2::Result result = s2.Run();
LOG(INFO) << "Final execution status: " << result.ToString();
Exiting a sandbox running asynchronously
If the sandbox has been running asynchronously, then two options are available
for termination. First, you can just wait for the completion of the Sandboxee
and receive the final execution status:
sandbox2::Result result = s2.AwaitResult();
LOG(INFO) << "Final execution status: " << result.ToString();
Alternatively, you can kill the Sandboxee at any time, but it's still
recommended to call AwaitResult()
because the Sandboxee might terminate
because of another reason in the meantime:
s2.Kill();
sandbox2::Result result = s2.AwaitResult();
LOG(INFO) << "Final execution status: " << result.ToString();
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-04-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-22 UTC."],[[["Exiting a synchronously running sandbox requires no extra steps as the `Run` function only returns after the Sandboxee is finished."],["Asynchronously running sandboxes can be terminated by waiting for completion with `AwaitResult()` or by forcefully killing the Sandboxee with `Kill()` followed by `AwaitResult()` to retrieve the final status."]]],[]]