-38 in eax in the syscall entry, apparently ENOSYS (the function is not implemented) and is placed there syscall_trace_entry in arch / x86 / kernel / entry_32.S. I believe it is safe to assume that it will always be present on an entry in syscall, however it may also be present on syscall if syscall returns ENOSYS.
Personally, I always just kept track of whether I had syscall in the record or output when using ptrace, although I saw some code based on ENOSYS. (I assume you are using ptrace). I believe that this will not work if the process happens inside a system call when connected to it, but I was lucky not to encounter this problem.
I quickly looked at the sources of strace, and I think it monitors the state, as there is a comment saying: "We are joining an already running process. Try to find out the state of the process in syscalls to handle the first event well." and a little after that, he said: "The process falls asleep in the middle of a system call. Fake a write event in syscall."
In short, a value cannot be safely used to differentiate an output record. However, I'm not sure if tracking it manually is the best way, since I actually don't have a source that will definitely tell you to use this technique, sorry. :)
Aleksi Torhamo
source share