How to show all users processes using `top -m` command in Alpine Docker container?

I want to watching the processes RSS in alpine container, so I using top -m switch show memory mode. But it shown processes that is current user, not all users processes. Is this behavior by design or a bug? I know the ps command can achieve my goal, but I’m just curious about this behavior of busybox command top -m.

# 1. start container
docker run -it --rm --name top_cmd alpine:3.19.3 /bin/sh
# and run `top -m` in this container
top -m

# 2. attach top_cmd container using other user like guest
docker exec -it -uguest top_cmd /bin/sh
# and run `top -m` in this container at same time
top -m

# 3. run ps command in this container at same time
docker exec -it top_cmd ps
# output
PID   USER     TIME  COMMAND
    1 root      0:00 /bin/sh    ### first step process
   16 root      0:00 top -m     ### first step process
   18 guest     0:00 /bin/sh    ### second step process
   24 guest     0:00 top -m     ### second step process
   25 root      0:00 ps

# watch this 1 and 2 step top command output, 
# they are only showing current user processes, even root.

This question might require a lot of research, so I thank the responder in advance.

Read more here: Source link