nmh-workers
[Top] [All Lists]

Re: [nmh-workers] closefds() _before_ fork?

2019-04-23 09:25:58
Hi Ken,

they called getdtablesize() on Linux, which it seems returns a smaller
number than getrlimit().

That's surprising.  I thought getdtablesize() was effectively

     return getrlimit(RLIMIT_NOFILE, &ru) < 0 ? OPEN_MAX : ru.rlim_cur;

That seems to match /lib/libc.a here, if I squint a bit, assuming
OPEN_MAX is 256.

    0000000000000000 <__getdtablesize>:
       0:   f3 0f 1e fa             endbr64 
       4:   48 83 ec 28             sub    $0x28,%rsp
       8:   bf 07 00 00 00          mov    $0x7,%edi
       d:   64 48 8b 04 25 28 00    mov    %fs:0x28,%rax
      14:   00 00 
      16:   48 89 44 24 18          mov    %rax,0x18(%rsp)
      1b:   31 c0                   xor    %eax,%eax
      1d:   48 89 e6                mov    %rsp,%rsi
      20:   e8 00 00 00 00          callq  25 <__getdtablesize+0x25>
                            21: R_X86_64_PLT32      __getrlimit-0x4
      25:   8b 14 24                mov    (%rsp),%edx
      28:   85 c0                   test   %eax,%eax
      2a:   78 1c                   js     48 <__getdtablesize+0x48>
      2c:   48 8b 4c 24 18          mov    0x18(%rsp),%rcx
      31:   64 48 33 0c 25 28 00    xor    %fs:0x28,%rcx
      38:   00 00 
      3a:   89 d0                   mov    %edx,%eax
      3c:   75 11                   jne    4f <__getdtablesize+0x4f>
      3e:   48 83 c4 28             add    $0x28,%rsp
      42:   c3                      retq   
      43:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
      48:   ba 00 01 00 00          mov    $0x100,%edx
      4d:   eb dd                   jmp    2c <__getdtablesize+0x2c>
      4f:   ff 15 00 00 00 00       callq  *0x0(%rip)        # 55 
<__getdtablesize+0x55>
                            51: R_X86_64_GOTPCRELX  __stack_chk_fail-0x4

-- 
Cheers, Ralph.

-- 
nmh-workers
https://lists.nongnu.org/mailman/listinfo/nmh-workers

<Prev in Thread] Current Thread [Next in Thread>