Kid.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
3 *
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.
7 */
8
9#ifndef SQUID_IPC_KID_H
10#define SQUID_IPC_KID_H
11
12#include "SquidString.h"
13#include "tools.h"
14
17class Kid
18{
19public:
20
22 enum { badFailureLimit = 4 };
23
25 enum { fastFailureTimeLimit = 10 }; // seconds
26
27public:
28 Kid();
29
30 Kid(const char *role, const int id);
31
33 void start(pid_t cpid);
34
36 void stop(PidStatus const exitStatus);
37
39 bool running() const;
40
42 bool shouldRestart() const;
43
45 pid_t getPid() const;
46
48 bool hopeless() const;
49
52
54 time_t deathDuration() const;
55
57 bool calledExit() const;
58
60 int exitStatus() const;
61
63 bool calledExit(int code) const;
64
66 bool exitedHappy() const;
67
69 bool signaled() const;
70
72 int termSignal() const;
73
75 bool signaled(int sgnl) const;
76
78 SBuf processName() const;
79
81 SBuf gist() const;
82
83private:
84 void reportStopped() const;
85
86 // Information preserved across restarts
88 int processId = 0;
89 int badFailures = 0;
90
91 // Information specific to a running or stopped kid
92 pid_t pid = -1;
93 time_t startTime = 0;
94 time_t stopTime = 0;
95 bool isRunning = false;
97};
98
99// TODO: processes may not be kids; is there a better place to put this?
100
102typedef enum {
107 pkHelper = 8
109
111extern int TheProcessKind;
112
113#endif /* SQUID_IPC_KID_H */
114
ProcessKind
process kinds
Definition: Kid.h:102
@ pkWorker
general-purpose worker bee
Definition: Kid.h:105
@ pkCoordinator
manages all other kids
Definition: Kid.h:104
@ pkDisker
cache_dir manager
Definition: Kid.h:106
@ pkHelper
general-purpose helper child
Definition: Kid.h:107
@ pkOther
we do not know or do not care
Definition: Kid.h:103
int TheProcessKind
ProcessKind for the current process.
Definition: Kid.cc:21
Definition: Kid.h:18
time_t deathDuration() const
Definition: Kid.cc:179
bool calledExit() const
returns true if the process terminated normally
Definition: Kid.cc:121
int exitStatus() const
returns the exit status of the process
Definition: Kid.cc:127
void start(pid_t cpid)
called when this kid got started, records PID
Definition: Kid.cc:34
pid_t pid
current (for a running kid) or last (for stopped kid) PID
Definition: Kid.h:92
bool running() const
returns true if tracking of kid is stopped
Definition: Kid.cc:91
SBuf processName() const
returns kid name
Definition: Kid.cc:163
void forgetFailures()
forgets all past failures, ensuring that we are not hopeless()
Definition: Kid.h:51
SBuf processRole
Definition: Kid.h:87
SBuf gist() const
Definition: Kid.cc:171
time_t stopTime
last termination time
Definition: Kid.h:94
Kid()
Definition: Kid.cc:23
bool hopeless() const
whether the failures are "repeated and frequent"
Definition: Kid.cc:115
void stop(PidStatus const exitStatus)
called when kid terminates, sets exiting status
Definition: Kid.cc:47
bool isRunning
whether the kid is assumed to be alive
Definition: Kid.h:95
time_t startTime
last start time
Definition: Kid.h:93
@ fastFailureTimeLimit
Definition: Kid.h:25
bool signaled() const
returns true if the kid was terminated by a signal
Definition: Kid.cc:145
int badFailures
number of "repeated frequent" failures
Definition: Kid.h:89
bool exitedHappy() const
whether the process exited with code 0
Definition: Kid.cc:139
pid_t getPid() const
returns current pid for a running kid and last pid for a stopped kid
Definition: Kid.cc:108
int termSignal() const
returns the number of the signal that caused the kid to terminate
Definition: Kid.cc:151
bool shouldRestart() const
returns true if master should restart this kid
Definition: Kid.cc:97
PidStatus status
exit status of a stopped kid
Definition: Kid.h:96
@ badFailureLimit
Definition: Kid.h:22
void reportStopped() const
describes a recently stopped kid
Definition: Kid.cc:66
int processId
Definition: Kid.h:88
Definition: SBuf.h:94
unsigned char code
Definition: html_quote.c:20
int PidStatus
Definition: tools.h:91

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors