diff --git a/bin/emu b/bin/emu index 1392220..3dc1a59 100755 --- a/bin/emu +++ b/bin/emu @@ -66,8 +66,12 @@ cmd_list() { # line, so this cannot match the shell running it: that shell's # command line contains this pattern, and a `ps | awk` that matches # itself reports the size of the shell. + # Whole argument rather than a prefix, for the reason `cmd_up` + # gives: with both up, a substring match reported ai-app-2's size + # against ai-app, which is a number that looks entirely plausible. rss=$(ps -eo rss=,comm=,args= | - awk -v want="-avd $name" '$2 ~ /^qemu-system/ && index($0, want) {print int($1/1024); exit}') + awk -v want="-avd $name" '$2 ~ /^qemu-system/ && + match($0, want "([[:space:]]|$)") {print int($1/1024); exit}') printf ' %-16s %-24s %s\n' "$serial" "$name" "${rss:+$rss MB}" done < <(running_avds "$adb") [ "$found" = true ] || echo " (none attached)" @@ -206,7 +210,15 @@ cmd_up() { # A stray process for this AVD that never registered with adb. The # bracketed first character keeps the pattern from matching the shell # running this script, which would kill it mid-flight. - pkill -f "[e]mulator.*-avd $avd" >/dev/null 2>&1 || true + # + # The trailing boundary is the other half, and it is not decoration: an + # AVD name is a *prefix* of every longer one, so `-avd ai-app` matched + # `-avd ai-app-2` and starting one checkout's emulator silently killed + # another checkout's. That is the exact interference this whole tool + # exists to prevent, and it looked from the other side like an emulator + # dying on its own -- twice, on 2026-08-31, before the pattern was the + # suspect. Match the name as a whole argument, never as a prefix. + pkill -f "[e]mulator.*-avd $avd([[:space:]]|\$)" >/dev/null 2>&1 || true log="/tmp/$avd-emulator.log" rm -f "$log"