]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kid.cc
2 * DEBUG: section 54 Interprocess Communication
14 int TheProcessKind
= pkOther
;
24 Kid::Kid(const String
& kid_name
):
33 /// called when this kid got started, records PID
34 void Kid::start(pid_t cpid
)
44 /// called when kid terminates, sets exiting status
45 void Kid::stop(status_type exitStatus
)
48 assert(startTime
!= 0);
54 if ((stop_time
- startTime
) < fastFailureTimeLimit
)
57 badFailures
= 0; // the failures are not "frequent" [any more]
62 /// returns true if tracking of kid is stopped
63 bool Kid::running() const
68 /// returns true if master process should restart this kid
69 bool Kid::shouldRestart() const
75 signaled(SIGKILL
) || // squid -k kill
76 signaled(SIGINT
) || // unexpected forced shutdown
77 signaled(SIGTERM
)); // unexpected forced shutdown
80 /// returns current pid for a running kid and last pid for a stopped kid
81 pid_t
Kid::getPid() const
87 /// whether the failures are "repeated and frequent"
88 bool Kid::hopeless() const
90 return badFailures
> badFailureLimit
;
93 /// returns true if the process terminated normally
94 bool Kid::calledExit() const
96 return (pid
> 0) && !running() && WIFEXITED(status
);
99 /// returns the exit status of the process
100 int Kid::exitStatus() const
102 return WEXITSTATUS(status
);
105 /// whether the process exited with a given exit status code
106 bool Kid::calledExit(int code
) const
108 return calledExit() && (exitStatus() == code
);
111 /// whether the process exited with code 0
112 bool Kid::exitedHappy() const
114 return calledExit(0);
117 /// returns true if the kid was terminated by a signal
118 bool Kid::signaled() const
120 return (pid
> 0) && !running() && WIFSIGNALED(status
);
123 /// returns the number of the signal that caused the kid to terminate
124 int Kid::termSignal() const
126 return WTERMSIG(status
);
129 /// whether the process was terminated by a given signal
130 bool Kid::signaled(int sgnl
) const
132 return signaled() && (termSignal() == sgnl
);
136 const String
& Kid::name() const