add comments documenting use of negative IDs for PGIDs in events

This commit is contained in:
David Adam 2017-04-23 21:58:26 +08:00
parent b8bf567514
commit 8612ac592d
2 changed files with 3 additions and 1 deletions

View file

@ -128,6 +128,7 @@ wcstring event_get_desc(const event_t &e) {
if (e.param1.pid > 0) {
result = format_string(_(L"exit handler for process %d"), e.param1.pid);
} else {
// In events, PGIDs are stored as negative PIDs
job_t *j = job_get_from_pid(-e.param1.pid);
if (j)
result = format_string(_(L"exit handler for job %d, '%ls'"), j->job_id,
@ -209,6 +210,7 @@ static wcstring event_desc_compact(const event_t &event) {
} else if (event.param1.pid > 0) {
res = format_string(L"EVENT_EXIT(pid %d)", event.param1.pid);
} else {
// In events, PGIDs are stored as negative PIDs
job_t *j = job_get_from_pid(-event.param1.pid);
if (j)
res = format_string(L"EVENT_EXIT(jobid %d: \"%ls\")", j->job_id,

View file

@ -53,7 +53,7 @@ struct event_t {
/// The type-specific parameter. The int types are one of the following:
///
/// signal: Signal number for signal-type events.Use EVENT_ANY_SIGNAL to match any signal
/// pid: Process id for process-type events. Use EVENT_ANY_PID to match any pid.
/// pid: Process id for process-type events. Use EVENT_ANY_PID to match any pid. (Negative values are used for PGIDs).
/// job_id: Job id for EVENT_JOB_ID type events
union {
int signal;