Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

gdb puts the debugged process in its own pgrp and sets the terminal to that pgrp. (Try e.g. ps j on the PIDs of gdb and your program being debugged.)

Quoted from here.

And what does it mean by ps j on the PIDs of gdb and your program being debugged,does that mean ps j PID?I don't get anything special from this though...

Basically I don't understand what that article is talking about,can anyone explain it in more great details?

share|improve this question
add comment

1 Answer

A “pgrp” is a process group. ps j lists the process group ID (the column is called PGID). The PGID of a process is typically itself or its parent's process group, but can be arbitrarily set with setpgid(). Process groups control what processes receive job control signals. I think gdb moves the process to its own group so as to avoid having the process receive job control signals that would mess up gdb's control over the process.

The bug report is about using gdb with a program that uses sigwait. sigwait allows a process to receive a signal in an underhand way: instead of being delivered to the process in the usual manner, the signal is removed from the pending queue and sigwait returns. This is mainly useful to arrange for a signal to be always delivered to a particular thread: block the signal, but have a thread consume it by running sigwait.

Since the signal is not actually delivered to the process, ptrace sees nothing, and so gdb isn't notified that the process has underhandedly consumed the signal.

The debate in the bug report is about whether the kernel should be modified so that ptrace sees something when the signal is consumed through sigwait, or whether gdb should handle this situation differently. I don't know enough about this to take sides.

share|improve this answer
    
Do you understand the explanation in that bug that says it's not a bug? –  locale Jun 10 '11 at 7:41
    
@locale: I've expanded my answer, but deciding whether it's a bug or not is beyond my level of expertise. P.S. This is getting really into developper territory; I've recommended that your question be migrated to Stack Overflow, and I recommend that you create an account there and associate it with your Server Fault account. –  Gilles Jun 10 '11 at 9:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.