meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
git:gitlab:runner:shell [2022/01/05 18:07] niziakgit:gitlab:runner:shell [2022/01/24 13:25] (current) niziak
Line 32: Line 32:
 </file> </file>
  
 +<file bash tools/ci/launch_job.sh>
 +#!/bin/bash
 +#_term() {
 +#    echo "$0 caught SIGTERM signal!"
 +#    trap - SIGTERM
 +#    kill -TERM $child $$
 +#}
 +
 +launch_job() {
 +    PARENT=$1
 +    shift
 +    "$@" &
 +    CHILD=$!
 +    trap "trap - SIGTERM; kill -TERM $CHILD $$" SIGTERM
 +
 +    while sleep 1; do
 + if [ ! -e /proc/$PARENT ]; then 
 +     echo "Parent PID $PARENT disappears, terminating child $CHILD"
 +     kill -TERM $CHILD
 +     exit
 + fi
 +
 + if [ ! -e /proc/$CHILD ]; then
 +     wait $CHILD
 +     trap - SIGTERM
 +     exit $?
 + fi
 +    done
 +}
 +
 +#trap _term SIGTERM
 +#launch_job $$ "$@" &
 +#echo "$0 Waiting for $! to finish"
 +#wait $!
 +
 +launch_job $PPID "$@"
 +</file>