Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
This repository was archived by the owner on Jan 15, 2026. It is now read-only.

Thekick_off method is broken for AndroidTarget #623

Closed

Description

@marcbonnici

The kick_off method with Android Target is currently broken, it either exhibits blocking behaviour on the command to be ran or fails to run the command correctly.

Example blocking behaviour reproducer:

from devlib import AndroidTarget
target = AndroidTarget()
target.kick_off('sleep 10; echo "Completed" > /sdcard/sleep.log')   # This command blocks until the command completes.

Example failure to execute reproducers:

target.kick_off('echo "Testing" > /sdcard/testing')
target.execute('cat /sdcard/testing')
"nohup: can't execute 'echo': No such file or directory\n"
target.kick_off('ls')
TargetTransientError: adb has returned early; did not get an exit code. Was kill-server invoked?
OUTPUT:
-----

0
nohup: appending output to nohup.out

-----
STDERR:
-----

-----

Activity

  1. douglas-raillard-arm commented on Apr 4, 2023

    @douglas-raillard-arm
    Collaborator

    So I had a go at it, here are my observations:

    • SSH and Android have different kick_off() implementation
    • The SSH version properly does not block in the first case
    • The android version does block, because we lack a level of sh -c:
    (export PATH=/root/devlib-target/bin:$PATH && export LC_ALL=C && cd /root/devlib-target && /root/devlib-target/bin/busybox nohup sleep 10; echo "Completed" &) 2>&1
    

    and it should be:

    (export PATH=/root/devlib-target/bin:$PATH && export LC_ALL=C && cd /root/devlib-target && /root/devlib-target/bin/busybox nohup sh -c 'sleep 10; echo "Completed"' &) 2>&1
    
    • This error is not so surprising as echo is a shell builtin. Often there is also a binary but I guess not always on android.
    "nohup: can't execute 'echo': No such file or directory\n"
    
    • I could not reproduce this one but it's easily explained:
    target.kick_off('ls')
    TargetTransientError: adb has returned early; did not get an exit code. Was kill-server invoked?
    

    nohup wrote this line to stdout:

    nohup: appending output to nohup.out
    

    after the exit code. Unfortunately, adb_shell() parses the last line as the exit code 💥 . Should be easily fixable by redirecting nohup output to /dev/null

    So overall I'd suggest:

    • Getting rid of the per-target implementation. That is a generic feature that can be implemented on top of other generic features.
    • The generic implementation should use nohup, but 1) redirect all output to /dev/null and 2) use quote(command) and interpolate that in sh -c {}.
    1. will fix both the blocking issue and the shell builtin issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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