Skip to content

Commit 3d6baa2

Browse files
committed
Fix snapshot restoration
1 parent bfe89fc commit 3d6baa2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

graalpython/graalpy_graalos_standalone_payload/README_GRAALOS_STANDALONE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,12 @@ bin/graalpy --graalhost.run_snapshot=/path/to/persistIso...
227227
Restoring a snapshot uses the saved process state. It does not take additional
228228
Python command-line arguments on the same invocation.
229229

230+
When `allow_signal_self_snapshot` is enabled, the launcher keeps the generated
231+
expanded endpoint config under `tmp/graalpy-sandbox.*` instead of deleting it
232+
at process exit. Snapshot restore needs that original directory to remain
233+
available because the saved endpoint configuration records it as
234+
`endpoint_config_path`.
235+
230236
### Show Graalhost Diagnostics
231237

232238
For launcher-level troubleshooting:

graalpython/graalpy_graalos_standalone_payload/graalpy-sandbox-launcher.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ config="${standalone_home}/config.json"
6767
tmp_root="${standalone_home}/tmp"
6868
launcher_verbose=false
6969
launcher_show_help=false
70+
cleanup_tmpdir=true
7071

7172
if [ ! -x "$graalhost" ]; then
7273
echo "missing or non-executable GraalHost binary: $graalhost" >&2
@@ -94,8 +95,17 @@ if [ -z "$tmp_base" ] || [ ! -d "$tmp_base" ]; then
9495
tmp_base="$tmp_root"
9596
fi
9697

98+
# Snapshot restore reuses the endpoint config persisted in the snapshot. When
99+
# self-snapshotting is enabled, keep the generated config directory so the
100+
# snapshotted endpoint_config_path still exists on resume.
101+
if grep -Eq '^[[:space:]]*"allow_signal_self_snapshot"[[:space:]]*:[[:space:]]*true([[:space:]]*[,}])' "$config"; then
102+
cleanup_tmpdir=false
103+
fi
104+
97105
tmpdir="$(mktemp -d "${tmp_base}/graalpy-sandbox.XXXXXXXXXX")"
98-
trap 'rm -rf "$tmpdir"' EXIT
106+
if [ "$cleanup_tmpdir" = "true" ]; then
107+
trap 'rm -rf "$tmpdir"' EXIT
108+
fi
99109
endpoint_config="${tmpdir}/config.json"
100110
"$expand_config" "$standalone_home" "$config" "$endpoint_config"
101111

0 commit comments

Comments
 (0)