Kid.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
17 class Kid
18 {
19 public:
20 
22  enum { badFailureLimit = 4 };
23 
25  enum { fastFailureTimeLimit = 10 }; // seconds
26 
27 public:
28  Kid();
29 
30  Kid(const String& kid_name);
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 
51  void forgetFailures() { badFailures = 0; }
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  const String& name() const;
79 
80 private:
81  void reportStopped() const;
82 
83  // Information preserved across restarts
86 
87  // Information specific to a running or stopped kid
88  pid_t pid;
89  time_t startTime;
90  time_t stopTime = 0;
91  bool isRunning;
93 };
94 
95 // TODO: processes may not be kids; is there a better place to put this?
96 
98 typedef enum {
99  pkOther = 0,
101  pkWorker = 2,
102  pkDisker = 4,
103  pkHelper = 8
104 } ProcessKind;
105 
107 extern int TheProcessKind;
108 
109 #endif /* SQUID_IPC_KID_H */
110 
bool calledExit() const
returns true if the process terminated normally
Definition: Kid.cc:129
int PidStatus
Definition: tools.h:94
general-purpose helper child
Definition: Kid.h:103
void reportStopped() const
describes a recently stopped kid
Definition: Kid.cc:75
void stop(PidStatus const exitStatus)
called when kid terminates, sets exiting status
Definition: Kid.cc:56
pid_t pid
current (for a running kid) or last (for stopped kid) PID
Definition: Kid.h:88
ProcessKind
process kinds
Definition: Kid.h:98
const String & name() const
returns kid name
Definition: Kid.cc:171
String theName
process name
Definition: Kid.h:84
PidStatus status
exit status of a stopped kid
Definition: Kid.h:92
void forgetFailures()
forgets all past failures, ensuring that we are not hopeless()
Definition: Kid.h:51
bool hopeless() const
whether the failures are "repeated and frequent"
Definition: Kid.cc:123
int termSignal() const
returns the number of the signal that caused the kid to terminate
Definition: Kid.cc:159
pid_t getPid() const
returns current pid for a running kid and last pid for a stopped kid
Definition: Kid.cc:116
void start(pid_t cpid)
called when this kid got started, records PID
Definition: Kid.cc:43
manages all other kids
Definition: Kid.h:100
general-purpose worker bee
Definition: Kid.h:101
bool running() const
returns true if tracking of kid is stopped
Definition: Kid.cc:98
int TheProcessKind
ProcessKind for the current process.
Definition: Kid.cc:21
unsigned char code
Definition: html_quote.c:20
time_t deathDuration() const
Definition: Kid.cc:177
we do not know or do not care
Definition: Kid.h:99
bool shouldRestart() const
returns true if master should restart this kid
Definition: Kid.cc:104
Definition: Kid.h:17
Kid()
Definition: Kid.cc:23
bool isRunning
whether the kid is assumed to be alive
Definition: Kid.h:91
bool signaled() const
returns true if the kid was terminated by a signal
Definition: Kid.cc:153
bool exitedHappy() const
whether the process exited with code 0
Definition: Kid.cc:147
time_t startTime
last start time
Definition: Kid.h:89
time_t stopTime
last termination time
Definition: Kid.h:90
int badFailures
number of "repeated frequent" failures
Definition: Kid.h:85
cache_dir manager
Definition: Kid.h:102
int exitStatus() const
returns the exit status of the process
Definition: Kid.cc:135

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors