#!/bin/bash
#
# This is the ela CIM provider daemon
DAEMON=ela_daemon

SIG_SEND=/sbin/ela_sig_send
#
# Use this if your daemon start as a service under /etc/init.d/
# 
PARENT_PID=`ps -eaf | grep $DAEMON | grep -v grep | awk '$3==1 {print $2}'`
#
# Use this if your daemon start in a shell (rarely happens, just under testing)
#
#PARENT_PID=`ps -eaf | grep $DAEMON | grep -v grep | awk '{print $2; exit}'`

if [ -z $PARENT_PID ] ; then
	echo "$DAEMON is not running"
	exit 1;
fi

CHILD_PIDS=`ps -ef | grep $DAEMON | grep -v grep | awk -v P_PID=$PARENT_PID '$3==P_PID {print $2}'`
RECID=$1

for p in $CHILD_PIDS; do
#	echo "child pid $p"
	$SIG_SEND -p ${p} -r ${RECID}
done
