From 7c07457d1edef7b52cb907f8bc8726110a6fe409 Mon Sep 17 00:00:00 2001 From: LI Qing Date: Wed, 6 Jan 2021 17:01:33 +0800 Subject: [PATCH] Enhance the check before running an instance --- tools/occlum | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/occlum b/tools/occlum index 2d041473..10ae85ea 100755 --- a/tools/occlum +++ b/tools/occlum @@ -95,6 +95,13 @@ check_has_built() { fi } +check_has_run() { + if pgrep --full "$instance_dir/build/bin/occlum-run" > /dev/null ; then + echo "Error: the process of current Occlum instance is running. Need to wait for the process to finish or kill it first." + exit 1 + fi +} + cmd_new() { if [ -z $@ ]; then echo "Error: target directory is not set" @@ -246,6 +253,7 @@ cmd_build() { cmd_run() { check_has_built + check_has_run SGX_MODE=$(cat $instance_dir/.sgx_mode) if [[ -n $SGX_MODE && "$SGX_MODE" != "HW" ]]; then