Ezt milyen nyelven írták?
#!/system/xbin/bb/ash
WAIT_RUNNING=1 # oom_adj check delay in seconds
WAIT_APPDETECT=20 # app detection delay in seconds
ADJ=1 # forces app's oom_adj to always be <= this
# standard for android:
# 0: foreground app
# 1-2: background service (connectbot = 1, google apps = 2)
# 7: app in backround
# 8: old bg app
APP="com.android.browser" # override with: 'hold com.name.of.app'
#LOGFILE="/sdcard/hold.log" # default: nothing
#PIDDIR="/sdcard" # default: /sqlite_stmt_journals (RAMdisk), will be '/sqlite_stmt_journals/hold-com.android.browser.pid'
#BUSYBOX=/opt/bin/busybox # default: path-search
if [ ! -e "$BUSYBOX" ]; then
if ! BUSYBOX=`which zbusybox`; then
export PATH="/system/xbin:/system/xbin/bb:/system/bin:/opt/bin:/data/local:/data/local/bin:$PATH"
if ! BUSYBOX=`which busybox`; then echo "Cannot find busybox! Bailing." > /dev/tty;exit 1;fi
fi
fi
if [ "x$LOGFILE" != "x" ]; then
l() {
echo "$@" >> $LOGFILE
echo "$@"
}
else
l() {
echo "$@"
}
fi
pidstuff() {
if [ "x$PIDDIR" = "x" ]; then
for d in "/sqlite_stmt_journals" "/data/local" "/system/sd" "/system/sd-ext" "/sdcard"; do
if [ -w "$d" ] && [ -d "$d" ]; then
PIDDIR="$d"
break
fi
done
fi
if [ "x$PIDDIR" = "x" ]; then
echo > /dev/tty
echo "Cannot find a place to write a .pid file, bailing." > /dev/tty; exit 1;
fi
PIDFILE="${PIDDIR}/hold-${APP}.pid"
}
pidkill() {
if [ -e "$PIDFILE" ]; then
oldpid=`cat $PIDFILE`
if [ "x$oldpid" != "x" ]; then
kill $oldpid 2> /dev/null
l "kill-old($oldpid): $?"
fi
fi
}
#######################
main() {
if [ "x$1" != "x" ]; then
APP="$1"
fi
pidstuff
l "$0: start - APP=$APP, BUSYBOX=$BUSYBOX, PIDFILE=$PIDFILE, LOGFILE=$LOGFILE";
pidkill
echo $$ > $PIDFILE
WAIT=$WAIT_APPDETECT
while : ; do
if [ "x$CMDLINE" != "x" ]; then
adj=$(cat /proc/$PID/oom_adj)
if [ $? -eq 0 ]; then
echo "[debug]: check /proc/$PID/oom_adj"
if [ $adj -gt $ADJ ]; then
echo $ADJ > /proc/$PID/oom_adj
l "$APP($PID): $adj -> $ADJ"
fi
else
unset PID
unset CMDLINE
WAIT=$WAIT_APPDETECT
l "$APP: lost"
fi
fi
if [ "x$PID" = "x" ]; then
PID=$($BUSYBOX pidof $APP)
echo "[debug]: pid $APP($?): $PID"
if [ "x$PID" != "x" ]; then
l "$APP($PID): found"
CMDLINE="/proc/$PID/cmdline"
WAIT=$WAIT_RUNNING
fi
fi
sleep $WAIT
done
}
#######################
if [ "x$1" = "x-k" ]; then
if [ "x$2" != "x" ]; then APP="$2"; fi
pidstuff
pidkill
elif [ "x$1" = "x-n" ]; then
main "$2"
elif [ "x$1" = "x-c" ]; then
if [ "x$2" != "x" ]; then APP="$2"; fi
pidstuff
if [ -e "$PIDFILE" ]; then
oldpid=`cat $PIDFILE`
if [ "x$oldpid" != "x" ]; then
cat /proc/$oldpid/cmdline| $BUSYBOX tr '\0' ' ' |
$BUSYBOX grep -q "$0.*$APP"
if [ $? -eq 0 ]; then
echo "$0 is running for $APP, pid: $oldpid"; exit 0
fi
fi
fi
echo "$0 is not running for $APP"; exit 1
else
if [ "x$1" != "x" ]; then APP="$1"; fi
$BUSYBOX nohup echo test > /dev/null
if [ $? != 0 ]; then echo "Problem with '$BUSYBOX nohup', returned: $!"; exit 1; fi
$BUSYBOX nohup $0 -n "$APP" 2> /dev/null 1> /dev/null &
echo "Launched into the background for '$APP'. Pid: $!"
fi





Ez bash programnyelv, ezen belül pedig egy ún. dd.completion
Ezek függvények amikkel tovább vannak egyszerűsítve a bash használata.
Ahogy az előttem szoló mondta ez egy shell script nyelv.
Azaz a rendszerhéjat lehet programozni vele
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!