2 * DEBUG: section 54 Interprocess Communication
18 int TheProcessKind
= pkOther
;
29 Kid::Kid(const String
& kid_name
):
39 /// called when this kid got started, records PID
40 void Kid::start(pid_t cpid
)
50 /// called when kid terminates, sets exiting status
51 void Kid::stop(status_type theExitStatus
)
54 assert(startTime
!= 0);
60 if ((stop_time
- startTime
) < fastFailureTimeLimit
)
63 badFailures
= 0; // the failures are not "frequent" [any more]
65 status
= theExitStatus
;
68 /// returns true if tracking of kid is stopped
69 bool Kid::running() const
74 /// returns true if master process should restart this kid
75 bool Kid::shouldRestart() const
81 signaled(SIGKILL
) || // squid -k kill
82 signaled(SIGINT
) || // unexpected forced shutdown
83 signaled(SIGTERM
)); // unexpected forced shutdown
86 /// returns current pid for a running kid and last pid for a stopped kid
87 pid_t
Kid::getPid() const
93 /// whether the failures are "repeated and frequent"
94 bool Kid::hopeless() const
96 return badFailures
> badFailureLimit
;
99 /// returns true if the process terminated normally
100 bool Kid::calledExit() const
102 return (pid
> 0) && !running() && WIFEXITED(status
);
105 /// returns the exit status of the process
106 int Kid::exitStatus() const
108 return WEXITSTATUS(status
);
111 /// whether the process exited with a given exit status code
112 bool Kid::calledExit(int code
) const
114 return calledExit() && (exitStatus() == code
);
117 /// whether the process exited with code 0
118 bool Kid::exitedHappy() const
120 return calledExit(0);
123 /// returns true if the kid was terminated by a signal
124 bool Kid::signaled() const
126 return (pid
> 0) && !running() && WIFSIGNALED(status
);
129 /// returns the number of the signal that caused the kid to terminate
130 int Kid::termSignal() const
132 return WTERMSIG(status
);
135 /// whether the process was terminated by a given signal
136 bool Kid::signaled(int sgnl
) const
138 return signaled() && (termSignal() == sgnl
);
142 const String
& Kid::name() const