upenn-acg/ProcessCache

Report exit status of root process

krs85 opened this issue · 6 comments

krs85 commented

We need to intercept wait4 (or waitpid?) and get the exit status of the “highest ranking” process of the execution. Right now, we don’t have a way to get it. We need to have the tracer spawn a dummy process, which spawns the actual program, and then we can have the dummy process wait on the program. Because we will be tracing the dummy process and the actual program, so we will see when the dummy process waits on the program, and we can get the exit status then.

Currently it is ProcessCache itself who spawns this root process. I think we can have Process$$ waitpid directly on the root process. This would avoid having to do any dummy process things.

You should be able to call waidpid(first_proc, ...)?; as the last thing in the trace_program function and I believe that would work?

krs85 commented

Oh cool! That's much simpler. Thanks for sharing, I will try that.

krs85 commented

If I call waitpid as the last part of trace_program, I get an ECHILD I think because at that point the child process has already exited?

Interesting. I'll look into why...

I think because at that point the child process has already exited?
But in general that should matter? waitpid works just as well on already exited children.

krs85 commented

Solved by expanding the TraceEvent::ProcessExited(pid) to also have the exit code, as it is info we already have at that point anyway :)