I created a program similar to "strace" which is able to log the syscalls.
Also I installed a webserver and watched the syscalls from 'strace' and from my program and compared them.
For each program, I initiated to the webserver a simple HTTP GET request which created several syscalls.
In my program:
I noticed that in a certain accept4() execution, the return value is (-11), meaning (minus 11) !
But that (-11) return value for accept4() should never happen.
I can't figure out why I get (-11) in register RAX when the accept4() syscall exits.
Attached the log of my program.
There are two accept4() syscalls (syscall number 288):
- Line 14: First accept4() syscall, entry.
- Line 18: First accept4() syscall, exit.
- Line 86: Second accept4() syscall, entry.
- Line 90: Second accept4() syscall, exit.
In the 'strace' program:
The suspected accept4() returns (-1) which 'strace' identifies as EAGAIN.
But according to 'errno' program, then:
~$ errno 1
EPERM 1 Operation not permitted
~$ errno 11
EAGAIN 11 Resource temporarily unavailable
Attached the log of the 'strace' program.
There are two accept4() syscalls (syscall number 288):
- Line 4: First accept4() syscall.
- Line 15: Second accept4() syscall.
My questions are:
- Why strace reports a different return value than my program?
- How should I properly interpret the (-11) that the second accept4() syscall returns?
Additional technical data:
Using gcc compiler with flags "-g -Wall" and linker flag "-lm".
The important data from "gcc -v" is:
Target: x86_64-linux-gnu
gcc version 11.3.0 (Ubuntu 11.3.0-1ubuntu1~22.04)
Include paths from "cpp -v":
/usr/lib/gcc/x86_64-linux-gnu/11/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include