-rwxr-xr-x | core/opiealarm/opieatd | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/core/opiealarm/opieatd b/core/opiealarm/opieatd index 3b9dc0e..fc2d421 100755 --- a/core/opiealarm/opieatd +++ b/core/opiealarm/opieatd @@ -3,20 +3,35 @@ timefile=/etc/resumeat +trap exit 0 SIGTERM SIGINT SIGQUIT + +echo $$ >/var/run/opieatd.pid + mkdir -p /var/spool/at [ -p /var/spool/at/trigger ] || mkfifo /var/spool/at/trigger while true; do - cat /var/spool/at/trigger | while read line; do - FILE=`ls -1 /var/spool/at/[0-9]* | head -n1` - echo "File = $FILE" - if [ -z "$FILE" ]; then + while read </var/spool/at/trigger dummy; do + FILES=`ls /var/spool/at/[0-9]* 2>/dev/null` + + if [ -z "$FILES" ]; then echo "clear resume at" echo "" >$timefile else - unixtime=`basename $FILE | cut -c1-10` + for i in "$FILES"; do + echo "File = $i" + + unixtime=`basename $i | cut -c1-10` + pid=`basename $i | cut -c12-` + + if [ -d /proc/$pid ]; then echo "Datestring = $unixtime" echo "$unixtime" >$timefile + else + rm -f $i + fi + done fi done done +exit 0 |