#!/bin/bash function p_invoke() { perf record -F1000 --call-graph dwarf -o /perf.data \ -- /nginx/objs/nginx \ -p /tmp \ -e /tmp/error.log \ -c /nginx.conf \ -g "daemon off;" } function invoke() { /nginx/objs/nginx \ -p /tmp \ -e /tmp/error.log \ -c /nginx.conf \ -g "daemon off;" \ $@ } function sigint_handler() { echo "sigint received. trigger again to kill." invoke -s quit trap - INT } function sigcont_handler() { echo "sigcont received. reloading nginx." invoke -s reload } trap 'sigint_handler' INT trap 'sigcont_handler' CONT p_invoke & wait echo "NGINX down. waiting until signalled..." sleep infinity