我正在尝试编写一个小型 shell 脚本,该脚本会从带有 busybox 的机顶盒向我的电视机发送一些命令。问题是它会生成大量的僵尸进程,当我尝试杀死所有进程时,我还杀死了一些不应该被杀死的音频进程......
这是我的脚本:
电视启动程序
#!/bin/sh
echo "ka 1 01" > /dev/ttyUSB0
read -t 5 response < /dev/ttyUSB0
echo "xb 1 70" > /dev/ttyUSB0
read -t 2 response < /dev/ttyUSB0
echo "kf 1 32" > /dev/ttyUSB0
read -t 2 response < /dev/ttyUSB0
echo "km 1 01" > /dev/ttyUSB0
#killall sh
电视台
#!/bin/sh
echo "ka 1 00" > /dev/ttyUSB0
#killall sh
我这样称呼它们(脚本的一部分):
case "$1" in
led-on)
echo 3 > /sys/class/leds/mag-front-led/mode
nohup sh /home/default/tvstop.sh &
;;
led-off)
echo 2 > /sys/class/leds/mag-front-led/mode
nohup sh /home/default/tvstart.sh &
;;
那么,我该如何正确终止它们呢?这就是僵尸的样子:
3637 root Z [sh]
3660 root Z [sh]
3696 root Z [sh]
3719 root Z [sh]
3751 root Z [sh]
3766 root Z [sh]
3798 root Z [sh]
3829 root Z [sh]
3913 root Z [sh]
3984 root Z [sh]
4489 root 6960 S sshd: root@pts/0
4533 root 2704 S -sh
10478 root Z [sh]
10516 root Z [sh]
10574 root Z [sh]
10597 root Z [sh]
10630 root Z [sh]
10737 root Z [sh]
11072 root Z [sh]
11103 root Z [sh]
11413 root Z [sh]
11436 root Z [sh]
11457 root DW [STVID.InjecterT]
11458 root SW [STVID[0].MPEG2P]
11459 root DW [tfm_89287480]
11460 root SW [STVID[0].Produc]
11461 root SW [STVID[0].Displa]
11462 root SW [STVID[0].ErrorR]
11477 root Z [sh]
11500 root Z [sh]
11525 root Z [sh]
11548 root Z [sh]
11581 root Z [sh]
11605 root Z [sh]
11638 root Z [sh]
11661 root Z [sh]
11688 root Z [sh]
19185 root 2704 R ps