Comments (9)
Couldn't this be implemented easily with the "timeout" tool without having tini implement this itself?
ie,
$ docker run -it --rm debian:jessie timeout 5s sleep 10
$ echo $?
124
$ docker run -it --rm debian:jessie timeout 10s sleep 5
$ echo $?
0
from tini.
Counter example (busybox implementation of timeout):
/ # timeout -t 1 sh -c 'sleep 2 && echo foo &'
/ # foo
Point being: if the child forks & exits, timeout will exit with status 0.
from tini.
Correct, I get that same problem when using timeout -t 1 sh -c 'sleep 2 && echo foo &'
on debian. Your example would not run in tini
in docker anyway since the process that tini
would be tracking would have exited, making tini
exit, and thus the container would be destroyed (ie, docker run -it --rm busybox sh -c 'sleep 10 && echo foo &'
dies immediately, whether or not I use any combination of tini
and timeout
).
from tini.
Yeah, i have chosen a bad example there. I will think of another one if necessary.
from tini.
Hey @danilobuerger , thanks for your suggestion!
So, this feels a bit more involved that I'd intuitively envision Tini supporting (though that doesn't necessarily mean much... intuition can be wrong!)
But, for what it's worth, I'm working on having pre / post commands in #28 that run (as the name implies) before Tini starts your child and after it exits.
I think this feature would let you solve this problem without any additional work in Tini. Just point --pre
to an executable file containing the following script (e.g. pre.sh
):
#!/bin/sh
sh -c 'sleep 10 && echo "TIMEOUT" && kill -s TERM 1' &
Then, run:
tini --pre pre.sh -- your program goes here
And that should actually work (I've just tested it locally)
(you could use KILL
as well, which would kill Tini immediately and not your child, but yield a non-zero exit code just the same — and of course with a little more shell work you can send KILL directly to the child)
What do you think? If you want to try it out, the feature's already coded, so you can re-compile Tini and try it now.
Cheers,
from tini.
Now that I think about it, you probably don't even need --pre
to do this. Just use this as your ENTRYPOINT
instead of using Tini directly:
#!/bin/sh
sh -c 'sleep 10 && echo "TIMEOUT" && kill -s TERM 1' &
exec tini -- sh -c 'sleep 20'
Cheers,
from tini.
Actually, never mind. I had an error in my thinking. Everyone else was correct :-).
from tini.
Glad you sorted this out then : )
from tini.
Just for future reference: @tianon was correct, the timeout will work fine.
from tini.
Related Issues (20)
- Forward env vars HOT 3
- How come tini proxies signals to child processes if the sigcgt bits are all 0? HOT 1
- CentOS 7 - tini version detected as malware HOT 5
- SIGTERM not working with exec command in the entrypoint script HOT 4
- 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 3
- tini docker windows container HOT 1
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.