Dockerfile
:
FROM alpine:3.20
COPY a.c .
RUN apk add build-base \
&& gcc a.c
a.c
:
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
setbuf(stdout, NULL);
while (1) {
putchar('.');
sleep(1);
}
return EXIT_SUCCESS;
}
$ docker build -t i .
$ docker run --rm i ./a.out
...
$ docker exec `docker ps -q | head -1` apk add procps
$ docker exec `docker ps -q | head -1` ps -eHo pid,blocked,ignored,caught,args
PID BLOCKED IGNORED CAUGHT COMMAND
15 0000000000000000 0000000000000000 000000007391fef9 ps -eHo pid,blocked,ignored,caught,args
1 0000000000000000 0000000000000000 0000000000000000 ./a.out
$ docker exec `docker ps -q | head -1` kill 1
...
$ docker stop `docker ps -q | head -1`
(10 seconds delay)
a.rb
:
while true
print '.'
sleep 1
end
$ docker run --rm -tv "$PWD:/host" ruby:3.3.4-alpine ruby host/a.rb
...
$ docker exec `docker ps -q | head -1` ps -eHo pid,blocked,ignored,caught,args
PID BLOCKED IGNORED CAUGHT COMMAND
14 0000000000000000 0000000000000000 000000007391fef9 ps -eHo pid,blocked,ignored,caught,args
1 0000000000000000 0000000000000000 0000000042017e4f ruby host/a.rb
$ echo $((`echo 'ibase=16; 42017E4F' | bc` & (1 << 14)))
16384
$ docker exec `docker ps -q | head -1` kill 1