Found a very weird situation.
setting ulimit with ulimit command:
ulimit -s 5100000ulimit -c 1000000ulimit -n 4096
checking ulimit - all good
[lt@lt-hkg1-tsr01 ~]$ ulimit -acore file size (blocks, -c) 1000000data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 255870max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 4096pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 5100000cpu time (seconds, -t) unlimitedmax user processes (-u) 4096virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited[lt@lt-hkg1-tsr01 ~]$
now checking ulimit via cgexec
[lt@lt-hkg1-tsr03 ~]$ cgexec -g cpuset:/lt/default /bin/bash -c "ulimit -a"core file size (blocks, -c) 1000000data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 1031435max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 4096pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 8192cpu time (seconds, -t) unlimitedmax user processes (-u) 4096virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited[lt@lt-hkg1-tsr03 ~]$
as you can see core files and open files are correctbut stack size reset back to default (even I have a different value in /etc/security/limits.conf)
I found that this is a case in kernel 5.x (5.4 / 5.10 /5.12) but worked as expected in 3.x and 4.x
Is it a bug or feature?