[ELDK] Kill strange behaviour in a script

Giuseppe Modugno g.modugno at elettronika.it
Mon Aug 4 17:25:49 CEST 2008


Dear all,

I have two shell scripts, example.sh and flash.sh:
---
root:/tmpfs/tmp> cat example.sh
#!/bin/sh

while true; do
  read X
  ./flash.sh &
  FLASHPID=$!
  sleep 5
  kill $FLASHPID
done
---
root:/tmpfs/tmp> cat flash.sh
#!/bin/sh

while true; do
  echo "ON"
  sleep 1
  echo "OFF"
  sleep 1
done
---
example.sh waits for an input from the keyboard and launches the 
second script flash.sh. After some seconds, example.sh kills the 
second script that it launched.

Here what happens on my ARM system based on ELDK4.1 SELF ramdisk:
---
root:/tmpfs/tmp> ./example.sh

ON
OFF
ON
OFF
ON
736: Terminated

Killed
root:/tmpfs/tmp>
---
This first blank line corresponds to the RET key press and correctly 
example.sh spawns flash.sh that writes ON/OFF. After 5 seconds, 
example.sh kills flash.sh process (I think the line "736: Terminated" 
is a kernel message on the console).

The second blank line corresponds to the second RET key press, but in 
this case the main example.sh script dies without reason.

What happens? I tried both the scripts in Ubuntu on my PC and they 
works as expected.


More information about the eldk mailing list