author | sandman <sandman> | 2002-06-02 01:42:05 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-02 01:42:05 (UTC) |
commit | 2205558adae76dc40a5c0f2dd83226a4d1c67eae (patch) (side-by-side diff) | |
tree | e7e96aa694bab035c2c75f3c1b6dbceea07d4270 /core/opiealarm/opieatd | |
parent | 385a3d8034003a412fa73840bf985582bf6b4547 (diff) | |
download | opie-2205558adae76dc40a5c0f2dd83226a4d1c67eae.zip opie-2205558adae76dc40a5c0f2dd83226a4d1c67eae.tar.gz opie-2205558adae76dc40a5c0f2dd83226a4d1c67eae.tar.bz2 |
Reworked the whole system and introduced re-suspend. Effect is that the
iPAQ is re-suspended when woken up by the RTC (as opposed to the button)
and on AC. Timeout is currently hardcoded to 120sec.
-rwxr-xr-x | core/opiealarm/opieatd | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/core/opiealarm/opieatd b/core/opiealarm/opieatd index 3b9dc0e..fc2d421 100755 --- a/core/opiealarm/opieatd +++ b/core/opiealarm/opieatd @@ -2,21 +2,36 @@ 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` - echo "Datestring = $unixtime" - echo "$unixtime" >$timefile + 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 |