2017-07-28 14:48:19 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Converts the return of "sh wrapper.sh $@" into Lua format.
|
|
|
|
|
|
|
|
CURRENT_DIR=$(dirname "$0")
|
2020-02-02 19:35:21 +00:00
|
|
|
sh "${CURRENT_DIR}/wrapper.sh" "$@" >/dev/null 2>&1 &
|
2017-07-28 14:48:19 +00:00
|
|
|
JOB_ID=$!
|
|
|
|
|
|
|
|
while true; do
|
2020-02-02 19:35:21 +00:00
|
|
|
if ps -p ${JOB_ID} >/dev/null 2>&1; then
|
2017-07-28 14:48:19 +00:00
|
|
|
# Unblock f:read().
|
|
|
|
echo
|
|
|
|
else
|
2020-02-02 19:35:21 +00:00
|
|
|
wait ${JOB_ID}
|
2017-07-28 14:48:19 +00:00
|
|
|
EXIT_CODE=$?
|
2020-02-02 19:35:21 +00:00
|
|
|
if [ "${EXIT_CODE}" -eq "255" ]; then
|
2017-07-28 14:48:19 +00:00
|
|
|
TIMEOUT="true"
|
|
|
|
else
|
|
|
|
TIMEOUT="false"
|
|
|
|
fi
|
|
|
|
|
2020-02-02 19:35:21 +00:00
|
|
|
if [ "${EXIT_CODE}" -eq "127" ]; then
|
2017-07-28 14:48:19 +00:00
|
|
|
BADCOMMAND="true"
|
|
|
|
else
|
|
|
|
BADCOMMAND="false"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "return { \
|
2020-02-02 19:35:21 +00:00
|
|
|
result = ${EXIT_CODE}, \
|
|
|
|
timeout = ${TIMEOUT}, \
|
|
|
|
bad_command = ${BADCOMMAND}, \
|
2017-07-28 14:48:19 +00:00
|
|
|
}"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|