Go to file
agnostic-apollo 7b9b9b6224 fix(run-docker.sh): Fix docker exec not passing kill signals (ctrl+c) to commands in some cases leaving processes still running
If `--tty` is not passed to `docker exec` because stdout is not available (`[ ! -t 1 ]`), like due to redirection to file (`&> build.log`) or if stdin is not available (`< /dev/null`), then docker does not forward kill signals to the process started and they remain running.

To fix the issue, the `DOCKER_EXEC_PID_FILE_PATH` env variable with the value `/tmp/docker-exec-pid-<timestamp>` is passed to the process called with `docke exec` and the process started stores its pid in the file path passed. Traps are set in `run-docker.sh` that runs the `docker exec` command to receive any kills signals, and if it does, it runs another `docker exec` command to read the pid of the process previously started from `DOCKER_EXEC_PID_FILE_PATH` and then kills it and all its children.

See Also:

https://github.com/docker/cli/issues/2607
https://github.com/moby/moby/issues/9098
https://github.com/moby/moby/pull/41548
https://stackoverflow.com/questions/41097652/how-to-fix-ctrlc-inside-a-docker-container

Also passing `--init` to `docker run` to "Run an init inside the container that forwards signals and reaps processes", although it does not work for above cases, but may helpful in others. The `--init` flag changes will only engage on new container creation.

https://docs.docker.com/engine/reference/run/#specify-an-init-process

https://docs.docker.com/engine/reference/commandline/run/

```
./scripts/run-docker.sh ./build-package.sh -f libjpeg-turbo  &> build.log
^C
$ ./scripts/run-docker.sh ps -efww
Running container 'termux-package-builder' from image 'termux/package-builder'...
UID          PID    PPID  C STIME TTY          TIME CMD
builder        1       0  0 05:48 pts/0    00:00:00 bash
builder     9243       0  0 06:01 pts/1    00:00:00 bash
builder    28127       0  0 06:12 ?        00:00:00 /bin/bash ./build-package.sh -f libjpeg-turbo
builder    28141   28127  0 06:12 ?        00:00:00 /bin/bash ./build-package.sh -f libjpeg-turbo
builder    28449   28141  1 06:12 ?        00:00:00 ninja -w dupbuild=warn -j 8
builder    28656   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28657   28656 79 06:12 ?        00:00:01 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28694   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28695   28694 89 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28728   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28729   28728  0 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28731   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28734   28731  0 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28740   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28741   28740  0 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28744       0  0 06:12 pts/2    00:00:00 ps -efww
builder    28748   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28752   28748  0 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28753   28449  0 06:12 ?        00:00:00 /bin/sh -c /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28754   28753  0 06:12 ?        00:00:00 /home/builder/.termux-build/_cache/android-r23c-api-24-v0/bin/clang
builder    28755   28449  0 06:12 ?        00:00:00 ninja -w dupbuild=warn -j 8
$ ./scripts/run-docker.sh ./build-package.sh -f libjpeg-turbo  &> build.log
$ ./scripts/run-docker.sh ./build-package.sh -f libjpeg-turbo
Running container 'termux-package-builder' from image 'termux/package-builder'...
ERROR: Another build is already running within same environment.
```
2022-07-28 15:27:20 +05:00
.github ci(docker_image.yml): workaround for sometimes unstable ghcr.io 2022-07-23 11:32:57 +03:00
disabled-packages chore(disabled/*): fix linting errors for disabled packages 2022-06-30 10:26:27 +02:00
ndk-patches ndk-patches: Don't declare `sem_{open,close,unlink}` 2022-03-26 00:02:59 +09:00
packages termux_step_configure_cmake: Revert CMAKE_INSTALL_LIBDIR old behaviour changed in 2af00064 2022-07-28 15:27:20 +05:00
root-packages nexttrace-enhanced: update to 0.1.12-beta.2 2022-07-22 12:16:41 +00:00
sample explicitly set maintainer for each package 2020-12-20 15:16:34 +02:00
scripts fix(run-docker.sh): Fix docker exec not passing kill signals (ctrl+c) to commands in some cases leaving processes still running 2022-07-28 15:27:20 +05:00
x11-packages fix(x11/at-spi2-atk): change git branch 2022-07-23 00:12:14 +08:00
.gitattributes update .gitattributes 2020-08-27 21:40:58 +03:00
.gitignore monorepo: apply changes suggested by buttaface 2022-04-18 13:57:19 +05:30
CODEOWNERS CODEOWNERS: add @2096779623 as default codeowners 2022-07-19 21:14:19 +08:00
CONTRIBUTING.md chore(CONTRIBUTING.md): fix typo x11 -> root 2022-06-10 13:11:43 +05:30
LICENSE.md avoid long lines in LICENSE.md 2019-06-08 14:40:01 +03:00
README.md README: remove help-needed notice 2022-04-24 11:08:20 +02:00
build-all.sh fix(run-docker.sh): Fix docker exec not passing kill signals (ctrl+c) to commands in some cases leaving processes still running 2022-07-28 15:27:20 +05:00
build-package.sh fix(run-docker.sh): Fix docker exec not passing kill signals (ctrl+c) to commands in some cases leaving processes still running 2022-07-28 15:27:20 +05:00
clean.sh fix(run-docker.sh): Fix docker exec not passing kill signals (ctrl+c) to commands in some cases leaving processes still running 2022-07-28 15:27:20 +05:00
repo.json CI: specify distribution in repo.json as well 2022-04-20 16:37:36 +02:00

README.md

Termux packages

GitHub repo size Packages last build status Docker image status Repology metadata Join the chat at https://gitter.im/termux/termux Join the Termux discord server

Powered by FossHost

This project contains scripts and patches to build packages for the Termux Android application.

Quick how-to about Termux package management is available at Package Management. It also has info on how to fix repository is under maintenance or down errors when running apt or pkg commands.

Contributing

Read CONTRIBUTING.md and Developer's Wiki for more details.

Contacts

General mailing list: https://groups.io/g/termux

Developer mailing list: https://groups.io/g/termux-dev

General chat: https://gitter.im/termux/termux or #termux on IRC/libera.chat.

Developer chat: https://gitter.im/termux/dev.