0

I am testing ptrace and signals.

The problem is that when I am forwarding a signal with sigaction and then senting the interrupt signal to the process via kill(pid, SIGKILL) and after the ptrace(PTRACE_SYSCALL, pid, NULL, tracee_signal) the process is printed as zombie at the output of ps aux.

Only when I quit the "master" process, then the zombie process has its return status collected by wait (at the end of the "master" process") so it stops being a zombie.

When I receive a signal the signal handler is called and the value of the signal is assigned to a global variable declared as volatile sig_atomic_t gotsig (Rockkind).

So at the main loop of the tracer I check that global variable for a value >0 and then I kill(pid, gotsig);.

After that there is this ptrace(PTRACE_SYSCALL, pid, NULL, tracee_signal).

And then the process becomes zombie.

Why does that happen? Is that proper behaviour?

Addition:
Could it be because we have to explicitly wait the child after the latest ptrace call? So as to reap its exit status?

Chris
  • 3,619
  • 8
  • 44
  • 64

1 Answers1

0

Referring your addition: Yes

As long as a parent did not process the SIGCHLD sent because of a child's death, the child stays a zombie.

In case the parent dies while the child is a zombie, the child is inherited by init (typically pid 1) and under normal circumstances init does prcosess the pending SIGCHLD, which in turn leads to the child dieing properly.

alk
  • 69,737
  • 10
  • 105
  • 255