#include "squid.h"
#include "base/File.h"
#include "debug/Messages.h"
#include "fs_io.h"
#include "Instance.h"
#include "parser/Tokenizer.h"
#include "sbuf/Stream.h"
#include "SquidConfig.h"
#include "tools.h"
#include <cerrno>
Go to the source code of this file.
Functions | |
static SBuf | PidFilenameCalc () |
static SBuf | PidFileDescription (const SBuf &filename) |
static SBuf | PidFilename () |
static pid_t | GetOtherPid (File &pidFile) |
static bool | ProcessIsRunning (const pid_t pid) |
determines whether a given process is running at the time of the call More... | |
static void | ThrowIfAlreadyRunningWith (File &pidFile) |
quits if another Squid instance (that owns the given PID file) is running More... | |
static void | RemoveInstance () |
atexit() handler; removes the PID file created with Instance::WriteOurPid() More... | |
Variables | |
static SBuf | TheFile |
static SBuf | ThePidFileToRemove |
ties Instance::WriteOurPid() scheduler and RemoveInstance(void) handler More... | |
Function Documentation
◆ GetOtherPid()
|
static |
- Returns
- the PID of another Squid instance (or throws)
Definition at line 69 of file Instance.cc.
References CharacterSet::CR, debugs, CharacterSet::LF, File::readSmall(), TexcHere, TheFile, and ToSBuf().
Referenced by Instance::Other(), and ThrowIfAlreadyRunningWith().
◆ PidFileDescription()
- Returns
- PID file description for debugging messages and error reporting
Definition at line 52 of file Instance.cc.
References ToSBuf().
Referenced by PidFilename(), and RemoveInstance().
◆ PidFilename()
|
static |
Instance entry points are expected to call this first.
- Returns
- PidFilenameCalc() result while updating TheFile context
Definition at line 60 of file Instance.cc.
References PidFileDescription(), PidFilenameCalc(), and TheFile.
Referenced by Instance::Other(), Instance::ThrowIfAlreadyRunning(), and Instance::WriteOurPid().
◆ PidFilenameCalc()
|
static |
PidFilename() helper
- Returns
- PID file name or, if PID signaling was disabled, an empty SBuf
Definition at line 30 of file Instance.cc.
References SBuf::append(), SquidConfig::chroot_dir, Chrooted, Config, debugs, and SquidConfig::pidFilename.
Referenced by PidFilename().
◆ ProcessIsRunning()
|
static |
Definition at line 95 of file Instance.cc.
References debugs, pid, and xstrerr().
Referenced by ThrowIfAlreadyRunningWith().
◆ RemoveInstance()
|
static |
Definition at line 162 of file Instance.cc.
References SBuf::c_str(), SBuf::clear(), debugs, enter_suid(), Important, SBuf::isEmpty(), leave_suid(), PidFileDescription(), safeunlink(), Debug::StopCacheLogUse(), and ThePidFileToRemove.
Referenced by Instance::WriteOurPid().
◆ ThrowIfAlreadyRunningWith()
|
static |
Definition at line 107 of file Instance.cc.
References debugs, GetOtherPid(), pid, ProcessIsRunning(), TexcHere, TheFile, and ToSBuf().
Referenced by Instance::ThrowIfAlreadyRunning(), and Instance::WriteOurPid().
Variable Documentation
◆ TheFile
|
static |
Describes the (last) instance PID file being processed. This hack shortens reporting code while keeping its messages consistent.
Definition at line 25 of file Instance.cc.
Referenced by GetOtherPid(), PidFilename(), Instance::ThrowIfAlreadyRunning(), ThrowIfAlreadyRunningWith(), and Instance::WriteOurPid().
◆ ThePidFileToRemove
|
static |
Definition at line 158 of file Instance.cc.
Referenced by RemoveInstance(), and Instance::WriteOurPid().