Comments (3)
No, Tini does not make any assumptions about the meaning of the signal it receives and simply forwards it to its child.
The only signal-specific handling in Tini is a set of signals that are not passed on to its child:
Line 356 in 6ad9813
SIGTERM
nor SIGINT
are in this list.
It's most likely that Bash is the one with signal-specific handling here: when Tini proxies SIGTERM
to its child, that child is Bash, and Bash decides what to do with the signal. In this case, it looks like it's respectively proxying SIGINT
to your Python script and exiting immediately upon SIGTERM
.
The best approach here would be to remove the middleman (Bash) when you no longer need it. Assuming spinning up your Python web server is the last thing you do in your Bash script, this is trivial.
Just rewrite sig_bash.sh
as is:
#!/bin/bash
# Whatever set up you have already
do one thing
do another thing
# The exec part is what matters here
exec python sig_handle.py
Here, using exec
means "replace my Bash shell with Python". This does mean you cannot run anything in the Bash script after you call exec
, but that's probably OK since your Python script is presumably able to cleanup after itself in its own signal handlers.
Now, the effect of using exec
here is that, you'll have a process hierarchy that looks like Tini -> Python
as opposed to Tini -> Bash -> Python
, so when Tini proxies a signal to its child, that's no longer Bash: it's your Python process. This means your Python script will receive signals directly, and will be free to handle them however it sees fit.
See #72 for essentially the same issue.
Cheers,
from tini.
Gah, I looked for a duplicate issue and couldn't find one! Sorry about that.
But thank you very much for the explanation. You're spot on, it was the way bash handled SIGTERM
. Your suggestion worked great. Not only did it fix my problem, but I learned the behavior of bash exec
in the process!
from tini.
Gah, I looked for a duplicate issue and couldn't find one! Sorry about that.
No problem :)
But thank you very much for the explanation. You're spot on, it was the way bash handled
SIGTERM
. Your suggestion worked great. Not only did it fix my problem, but I learned the behavior of bashexec
in the process!
Happy to help!
from tini.
Related Issues (20)
- ownership of /proc/1/* is root even the user is non-root HOT 3
- Support setuid and setguid before execute command?
- Supress TRACE but show DEBUG HOT 1
- Event not generated when File change happens HOT 1
- About Tini version planning? HOT 2
- aarch64 version available? HOT 3
- Non-terminal signals are killing containers running with --init flag HOT 3
- stack-protector not work HOT 4
- [FATAL tini (7)] exec bash failed: No such file or directory HOT 3
- [CVE-2023-25139]tini-static executable seems vulnerable HOT 1
- example / explanation HOT 1
- How can I confirm that tini is running? HOT 1
- prctl(PR_SET_PDEATHSIG, ...) should be called after fork(), not before HOT 4
- MI6&termux&clang-16 build failed HOT 2
- Using "docker run --init" with arguments to tini HOT 2
- tini docker windows container HOT 1
- Command-line parsing is broken if compiled with TINI_MINIMAL
- tini not running as child subreaper on AWS Lambda HOT 4
- dnf/rpm install -y tini not working HOT 1
- Latest release changed to 0.18. then switched back to 0.19 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tini.