debugging rlimit
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Oct 14 13:22:00 GMT 2013
On Sep 25 15:45, Eric Blake wrote:
> 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.
You can workaround this problem by attaching to the process after it
started. In the dumbest possible way, you can add something like this
to main:
1 printf ("PID %u, waiting...\n", getpid ());
2 sleep (10);
3 printf ("Here I am\n");
Attach to the process during the sleep period, and, in GDB, set a
breakpoint to line 3 and continue execution.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-developers/attachments/20131014/ce487706/attachment.sig>
More information about the Cygwin-developers
mailing list