Why ulimit -c return 0, but the cat /proc/${pid}/limit show "unlimited", how to change it?

551 Views Asked by At
  1. How to set a process from unlimited to 0?
  2. How to set all the process from unlimited to 0?
2

There are 2 best solutions below

0
On

I don't think there is a command for this. There is a function 'prlimit()'. Example usage is given in the prlimit manpage.

0
On

In newer distro there is a command called prlimit based on function prlimit, but if you have an old distro, you can use gdb in this way:

(gdb) set $rlim = &{0, 0}
(gdb) set *$rlim[0] = -1
(gdb) set *$rlim[1] = -1
(gdb) p setrlimit(4, $rlim) #For the resource number you can look inside "/usr/include/bits/resource.h"