这是indexloc提供的服务,不要输入任何密码
Skip to content

termux-vibrate corrupts pipes in scripts #820

@BuriXon-code

Description

@BuriXon-code

Problem description

About problem

When run from a script, the termux-vibrate command terminates according to the shell/interpreter, but it can still block the terminal and corrupt pipes and standard streams for other commands executed afterwards. I did not notice this behavior on Android 13/14, but it appears on Android 15/16. As an example, in my implementation, running jq after termux-vibrate produces corrupted output.

Examples

The attached screenshots show, in order, the output using termux-vibrate -d 50 as the vibration engine (between output records), and in the second one the same output using echo -en "\a" (bell).

Termux_Usage

Bell_Usage

Steps to reproduce

Example Bash script to reproduce:

#!/data/data/com.termux/files/usr/bin/bash

while true; do
    raw=`termux-wifi-scaninfo 2>/dev/null || true`
    [ -z "$raw" ] && return 1

    printf "%s" "$raw" | jq -c '.[] | {ssid:.ssid,bssid:.bssid,rssi:.rssi,frequency_mhz:.frequency_mhz,capabilities:.capabilities}' | while IFS= read -r line; do
        ssid=$(printf "%s" "$line" | jq -r '.ssid')
        bssid=$(printf "%s" "$line" | jq -r '.bssid')
        rssi=$(printf "%s" "$line" | jq -r '.rssi')
        freq=$(printf "%s" "$line" | jq -r '.frequency_mhz')
        caps=$(printf "%s" "$line" | jq -r '.capabilities')
        echo "$ssid" "$bssid" "$rssi" "$freq" "$caps"
        case $1 in
            bell) echo -en "\a" ;;
            vibrate) termux-vibrate -d 50 ;;
        esac
    done
done

How to use:

  1. Run the script.
  2. If no parameter is given, everything works fine.
  3. If the parameter bell is used, everything works fine.
  4. If the parameter vibrate triggers termux-vibrate, the terminal may block and subsequent commands like jq produce corrupted output.

Expected behavior

termux-vibrate should execute the vibration without interfering with the terminal, pipes, or standard streams of other commands, regardless of Android version.

Additional information

  • termux-api application version: 0.53.0
  • termux-api package version (installed through apt): 0.59.1-1
  • Android OS version: 15/16
  • Device model: Nubia NX769J/NX809J

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions