#include <XrdSysUtils.hh>
Definition at line 36 of file XrdSysUtils.hh.
◆ XrdSysUtils()
XrdSysUtils::XrdSysUtils |
( |
| ) |
|
|
inline |
◆ ~XrdSysUtils()
XrdSysUtils::~XrdSysUtils |
( |
| ) |
|
|
inline |
◆ ExecName()
const char * XrdSysUtils::ExecName |
( |
| ) |
|
|
static |
Get the name of the current executable.
- Returns
- the full path of the executable invoked.
Definition at line 60 of file XrdSysUtils.cc.
62 static const char *myEname = 0;
70 if (myEname)
return myEname;
74 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
77 if ((epLen = readlink(
"/proc/self/exe", epBuff,
sizeof(epBuff)-1)) > 0)
79 myEname = strdup(epBuff);
83 #elif defined(__APPLE__)
85 uint32_t epLen =
sizeof(epBuff)-1;
86 if (!_NSGetExecutablePath(epBuff, &epLen))
88 myEname = strdup(epBuff);
92 #elif defined(__solaris__)
93 {
const char *epBuff = getexecname();
95 {
if (*epBuff ==
'/') myEname = strdup(epBuff);
96 else {
char *ename, *cwd = getcwd(0, MAXPATHLEN);
97 ename = (
char *)malloc(strlen(cwd)+1+strlen(epBuff)+1);
98 sprintf(ename,
"%s/%s", cwd, epBuff);
Referenced by XrdCl::DefaultEnv::GetMonitor().
◆ FmtUname()
int XrdSysUtils::FmtUname |
( |
char * |
buff, |
|
|
int |
blen |
|
) |
| |
|
static |
Format the uname information
- Parameters
-
buff | - pointer to the buffer to hold the uname as: <sysname> <release> [<version>] [<machine>] |
blen | - length of the buffer. |
- Returns
- the output of snprintf(buff, blen, ...);
Definition at line 117 of file XrdSysUtils.cc.
120 return snprintf(buff, blen,
"%s",
"windows");
122 struct utsname uInfo;
126 if (uname(&uInfo) < 0)
return snprintf(buff, blen,
"%s",
"unknown OS");
131 #if defined(__linux__)
132 return snprintf(buff, blen,
"%s %s", uInfo.sysname, uInfo.release);
133 #elif defined(__APPLE__) || defined(__FreeBSD__) || (defined(__FreeBSD__) || defined(__GLIBC__))
134 return snprintf(buff, blen,
"%s %s %s", uInfo.sysname, uInfo.release,
137 return snprintf(buff, blen,
"%s %s %s %s", uInfo.sysname, uInfo.release,
138 uInfo.version, uInfo.machine);
Referenced by XrdConfig::Configure().
◆ GetSigNum()
int XrdSysUtils::GetSigNum |
( |
const char * |
sname | ) |
|
|
static |
Get common signal number.
- Parameters
-
sname | - the signal name as in sigxxx or just xxx (see kill). |
- Returns
- =0 - unknown or unsupported signal.
-
!0 - the corresponding signal number.
Definition at line 165 of file XrdSysUtils.cc.
171 if (!strncmp(sname,
"sig", 3) || !strncmp(sname,
"SIG", 3)) sname += 3;
175 for (i = 0; i < snum; i++)
176 {
if (!strcmp(sname, sigtab[i].sname))
return sigtab[i].snum;}
Referenced by XrdSysLogger::ParseKeep().
◆ SigBlock() [1/2]
bool XrdSysUtils::SigBlock |
( |
| ) |
|
|
static |
Block common signals. This must be called at program start.
- Returns
- true - common signals are blocked.
-
false - common signals not blocked, errno has the reason.
Definition at line 188 of file XrdSysUtils.cc.
194 signal(SIGPIPE, SIG_IGN);
196 #ifdef ENABLE_COVERAGE
198 signal(SIGTERM, [](
int) { __gcov_dump(); _exit(EXIT_SUCCESS); });
204 sigaddset(&myset, SIGPIPE);
205 sigaddset(&myset, SIGCHLD);
210 sigaddset(&myset, SIGRTMAX);
211 sigaddset(&myset, SIGRTMAX-1);
216 return pthread_sigmask(SIG_BLOCK, &myset, NULL) == 0;
Referenced by XrdSysLogger::Bind(), and main().
◆ SigBlock() [2/2]
bool XrdSysUtils::SigBlock |
( |
int |
numsig | ) |
|
|
static |
Block a particular signal. This should be called at program start so that the block applies to all threads.
@aparam numsig - The signal value to be blocked.
- Returns
- true - signal is blocked.
-
false - signal not blocked, errno has the reason.
Definition at line 221 of file XrdSysUtils.cc.
227 if (sigemptyset(&myset) == -1 || sigaddset(&myset, numsig) == -1)
232 return pthread_sigmask(SIG_BLOCK, &myset, NULL) == 0;
The documentation for this class was generated from the following files: