0

I am trying to get the termination of a process with ptrace. I've already tried PTRACE_O_TRACEEXIT, but the process could end also with a return and the event will not be caught. What can I do? I would like a ptrace solution only, without waitpid

Maray97
  • 140
  • 1
  • 11
  • Why do you think it won't be caught? `return x;` from `main()` is equivalent to `exit(x);` – Barmar Mar 02 '23 at 17:36
  • @Barmar I was thinking the same, but if I put "return 0" it is not caught, if I put "exit(0)" it is caught – Maray97 Mar 02 '23 at 17:42
  • That should not be true. The [C standard](http://port70.net/~nsz/c/c11/n1570.html#5.1.2.2.3) specifically says "a return from the initial call to the main function is equivalent to calling the exit function". Can you add a [mre] that demonstrates the problem? – Barmar Mar 02 '23 at 17:48
  • @Barmar I am using ptrace in Honggfuzz and I've discovered that it acts differently. I guess it is something related with the instrumentation provided by Honggfuzz itself that changes the behavior of return, but not the exit – Maray97 Mar 03 '23 at 08:30
  • Sounds like something you should report as a bug in their github. – Barmar Mar 03 '23 at 15:53

0 Answers0