2 * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 /* DEBUG: section 54 Interprocess Communication */
20 int TheProcessKind
= pkOther
;
31 Kid::Kid(const String
& kid_name
):
41 /// called when this kid got started, records PID
42 void Kid::start(pid_t cpid
)
52 /// called when kid terminates, sets exiting status
53 void Kid::stop(status_type theExitStatus
)
56 assert(startTime
!= 0);
62 if ((stop_time
- startTime
) < fastFailureTimeLimit
)
65 badFailures
= 0; // the failures are not "frequent" [any more]
67 status
= theExitStatus
;
70 /// returns true if tracking of kid is stopped
71 bool Kid::running() const
76 /// returns true if master process should restart this kid
77 bool Kid::shouldRestart() const
83 signaled(SIGKILL
) || // squid -k kill
84 signaled(SIGINT
) || // unexpected forced shutdown
85 signaled(SIGTERM
)); // unexpected forced shutdown
88 /// returns current pid for a running kid and last pid for a stopped kid
89 pid_t
Kid::getPid() const
95 /// whether the failures are "repeated and frequent"
96 bool Kid::hopeless() const
98 return badFailures
> badFailureLimit
;
101 /// returns true if the process terminated normally
102 bool Kid::calledExit() const
104 return (pid
> 0) && !running() && WIFEXITED(status
);
107 /// returns the exit status of the process
108 int Kid::exitStatus() const
110 return WEXITSTATUS(status
);
113 /// whether the process exited with a given exit status code
114 bool Kid::calledExit(int code
) const
116 return calledExit() && (exitStatus() == code
);
119 /// whether the process exited with code 0
120 bool Kid::exitedHappy() const
122 return calledExit(0);
125 /// returns true if the kid was terminated by a signal
126 bool Kid::signaled() const
128 return (pid
> 0) && !running() && WIFSIGNALED(status
);
131 /// returns the number of the signal that caused the kid to terminate
132 int Kid::termSignal() const
134 return WTERMSIG(status
);
137 /// whether the process was terminated by a given signal
138 bool Kid::signaled(int sgnl
) const
140 return signaled() && (termSignal() == sgnl
);
144 const String
& Kid::name() const