The process in context here is 'android build environment'. To timeout normal tasks, one would do
#Timeout command 'do_task' in 10 seconds
timeout 10s do_task
However, when I try the same with android build environment, it doesn't seem to work. This is what happens instead:
box@boxputer:/media/box/backup/cr81x$ source build/envsetup.sh
box@boxputer:/media/box/backup/cr81x$ lunch aosp_arm-eng
Trying dependencies-only mode on a non-existing device tree?
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=12
TARGET_DEVICE=generic
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a-neon
TARGET_CPU_VARIANT=generic
HOST_ARCH=x86_64
HOST_2ND_ARCH=x86
HOST_OS=linux
HOST_OS_EXTRA=Linux-5.13.0-44-generic-x86_64-Zorin-OS-16.1
HOST_CROSS_OS=windows
HOST_CROSS_ARCH=x86
HOST_CROSS_2ND_ARCH=x86_64
HOST_BUILD_TYPE=release
BUILD_ID=SQ3A.220605.009.A1
OUT_DIR=out
PRODUCT_SOONG_NAMESPACES=device/generic/goldfish device/generic/goldfish-opengl hardware/google/camera hardware/google/camera/devices/EmulatedCamera device/generic/goldfish device/generic/goldfish-opengl
============================================
box@boxputer:/media/box/backup/cr81x$ timeout 10s mka bacon
timeout: failed to run command ‘mka’: No such file or directory
Here, 'mka bacon' is the build command, 'make' or 'm' could also be used, but they all result in the same error as mentioned above.
What I've tried additionally includes
# Spawn a child process:
(dosmth) & pid=$!
# in the background, sleep for 10 secs then kill that process
(sleep 10 && kill -9 $pid) &
( cmdpid=$BASHPID;
(sleep 10; kill $cmdpid) \
& while ! ping -w 1 www.goooooogle.com
do
echo crap;
done )
and other answers from This Particular Stackoverflow thread.
I've also tried another solution on a related thread
while one gave me success, it introduced a problem of its own(code below)
mka bacon &
sleep 10s
This however ensures that the process isn't terminated until 10 seconds have passed. Say I finish the build in 5 seconds. The process still won't exit. It won't exit till 10 seconds have passed, which isn't a desirable situation when a build produces an error.
And when I try the other answers from This Particular Stackoverflow thread, The process terminates after 10 seconds, but the entire terminal glitches, and the build still runs(at this stage even Ctrl+C doesn't work) My guess is that the build environment spawns its own child-processes with different PID's for the build?
If incase you're wondering what envsetup.sh is, Here's its paste