0

I found some sample code to keep a docker build container running until it gets stopped. It uses

/bin/ash -c "trap : TERM INT; sleep infinity & wait"

as parameter.

Why is the ':' needed? Another stackoverflow mentions the colon is just used for side effects, but here I'd assume TERM INT is needed as a trap argument.

gre_gor
  • 6,669
  • 9
  • 47
  • 52
Stefan K.
  • 7,701
  • 6
  • 52
  • 64
  • [The Bash manual page](https://www.man7.org/linux/man-pages/man1/bash.1.html) might be useful. Especially its [list of builtin commands](https://www.man7.org/linux/man-pages/man1/bash.1.html#SHELL_BUILTIN_COMMANDS). – Some programmer dude Jan 10 '22 at 13:44
  • 1
    Since `ash` is Posix compliant: The [`trap`](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#trap) function states that the [null-utility colon (`:`)](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_16) is an action. So in the end, it does nothing when TERM or INT are signalled. – kvantour Jan 10 '22 at 14:17

1 Answers1

3

The : is the command that will be executed on receipt of TERM or INT. It is a noop, so basically you can think of it as if the signals are ignored.

William Pursell
  • 204,365
  • 48
  • 270
  • 300