Default [Q] Leaving getevent without “-c count”

Hi,
for catching events I found:
http://forum.xda-developers.com/show....php?t=2233865

Now I want to build a shell were I can look for devices and then catch them and bind them to a action...

It's my first time I tried to write a shell script...

The script works if I don't have any devices witch sends continuously there daters:

Code:
Select Code
#!/system/bin/sh

[...]

device1="/dev/input/event4"
device2="/dev/input/event0"

while :; do

    getevent -q -t -c 2 | grep -e "$device1"  -e "$device2" | while IFS=' ' read  -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do 

            Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2" 

        done
        Result="$?"


        if [[ "$Result"  == "11" ]] then   
            input keyevent 85 #KEYCODE_MEDIA_PLAY_PAUSE
        fi  

done
..mapping looks like:

Code:
Select Code
Mapping() {  # "${ev_path/:}" "$ev_code" "$ev_value" "$deviceX1" "$deviceX2" (...)

    if [[ "$1" == "$4" && "$2" == "0139" && "$3" == "00000001" ]] then
        return 11 #Play/Pause
    fi
# (…) and so on
}


is there any way to write

Code:
Select Code
getevent -q -t -c 2 | grep -e "$device1"  -e "$device2" | while IFS=' ' read  -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do
to

Code:
Select Code
getevent -q -t | grep -e "$device1"  -e "$device2" | while IFS=' ' read  -r ev_t_brckt ev_time ev_path ev_type ev_code ev_value _; do #-r _ a; do 

        Mapping "${ev_path/:}" "$ev_code" "$ev_value" "$device1" "$device2" 
        if [ -n "$?" ]; then   
 >>>> exit / break /what ever 
        fi   
    done
I tried it with “exit”, “break” and “return” (and “kill $PID”) but getevent didn't want to exit :'(

any ideas?


(pleas be clement with my grammar.. it's not my native language )

kind regards, Veit