]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/Kid.cc
4 * DEBUG: section 54 Interprocess Communication
16 int TheProcessKind
= pkOther
;
26 Kid::Kid(const String
& kid_name
):
35 /// called when this kid got started, records PID
36 void Kid::start(pid_t cpid
)
46 /// called when kid terminates, sets exiting status
47 void Kid::stop(status_type exitStatus
)
50 assert(startTime
!= 0);
56 if ((stop_time
- startTime
) < fastFailureTimeLimit
)
59 badFailures
= 0; // the failures are not "frequent" [any more]
64 /// returns true if tracking of kid is stopped
65 bool Kid::running() const
70 /// returns true if master process should restart this kid
71 bool Kid::shouldRestart() const
77 signaled(SIGKILL
) || // squid -k kill
78 signaled(SIGINT
) || // unexpected forced shutdown
79 signaled(SIGTERM
)); // unexpected forced shutdown
82 /// returns current pid for a running kid and last pid for a stopped kid
83 pid_t
Kid::getPid() const
89 /// whether the failures are "repeated and frequent"
90 bool Kid::hopeless() const
92 return badFailures
> badFailureLimit
;
95 /// returns true if the process terminated normally
96 bool Kid::calledExit() const
98 return (pid
> 0) && !running() && WIFEXITED(status
);
101 /// returns the exit status of the process
102 int Kid::exitStatus() const
104 return WEXITSTATUS(status
);
107 /// whether the process exited with a given exit status code
108 bool Kid::calledExit(int code
) const
110 return calledExit() && (exitStatus() == code
);
113 /// whether the process exited with code 0
114 bool Kid::exitedHappy() const
116 return calledExit(0);
119 /// returns true if the kid was terminated by a signal
120 bool Kid::signaled() const
122 return (pid
> 0) && !running() && WIFSIGNALED(status
);
125 /// returns the number of the signal that caused the kid to terminate
126 int Kid::termSignal() const
128 return WTERMSIG(status
);
131 /// whether the process was terminated by a given signal
132 bool Kid::signaled(int sgnl
) const
134 return signaled() && (termSignal() == sgnl
);
138 const String
& Kid::name() const