Eric Blake
2013-09-25 21:45:07 UTC
How am I supposed to debug code related to rlimit, when it appears that
gdb/strace resets it to default values?
$ cat foo.c
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
int main(void) {
struct rlimit r;
if (!getrlimit(RLIMIT_NOFILE, &r))
printf("%ld %ld\n", r.rlim_cur, r.rlim_max);
return 0;
}
$ ./foo
256 3200
$ (ulimit -n 1000; ./foo)
1000 3200
$ (ulimit -n 1000; strace -o /dev/null ./foo)
256 3200
Since rlimit is intertwined with getdtablesize(), I'd like to be able to
debug a process that starts with a different limit than normal.
gdb/strace resets it to default values?
$ cat foo.c
#include <stdio.h>
#include <unistd.h>
#include <sys/resource.h>
int main(void) {
struct rlimit r;
if (!getrlimit(RLIMIT_NOFILE, &r))
printf("%ld %ld\n", r.rlim_cur, r.rlim_max);
return 0;
}
$ ./foo
256 3200
$ (ulimit -n 1000; ./foo)
1000 3200
$ (ulimit -n 1000; strace -o /dev/null ./foo)
256 3200
Since rlimit is intertwined with getdtablesize(), I'd like to be able to
debug a process that starts with a different limit than normal.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org