20#include "RConfigure.h"
52#if defined(R__SUN) || \
53 defined(R__LINUX) || defined(R__SOLARIS) || \
54 defined(R__FBSD) || defined(R__OBSD) || \
55 defined(R__MACOSX) || defined(R__HURD)
63#if defined(ULTRIX) || defined(R__SUN)
66#if defined(R__LINUX) || \
67 defined(R__FBSD) || defined(R__OBSD) || \
68 defined(R__LYNXOS) || defined(R__MACOSX) || defined(R__HURD)
69# include <sys/ioctl.h>
71#if defined(R__SOLARIS)
72# include <sys/select.h>
75# include <mach-o/dyld.h>
76# include <sys/mount.h>
77 extern "C" int statfs(
const char *file,
struct statfs *buffer);
78#elif defined(R__LINUX) || defined(R__HURD)
80#elif defined(R__FBSD) || defined(R__OBSD)
81# include <sys/param.h>
82# include <sys/mount.h>
85# include <sys/types.h>
86# include <sys/param.h>
87# include <sys/queue.h>
88# include <libprocstat.h>
92# include <sys/statfs.h>
100#include <sys/param.h>
104#include <sys/resource.h>
109#include <sys/socket.h>
110#include <netinet/in.h>
111#include <netinet/tcp.h>
112#include <arpa/inet.h>
116#if defined(R__SOLARIS)
117# include <sys/systeminfo.h>
118# include <sys/filio.h>
119# include <sys/sockio.h>
120# define HASNOT_INETATON
122# define INADDR_NONE (UInt_t)-1
126#if defined(R__SOLARIS)
131#if defined(MAC_OS_X_VERSION_10_5)
137# include <sys/param.h>
138# if __FreeBSD_version >= 900007
143#if defined(R__FBSD) || \
144 defined(R__OBSD) || defined(R__LYNXOS) || \
145 (defined(R__MACOSX) && !defined(MAC_OS_X_VERSION_10_5))
149#if defined(R__LYNXOS)
151 extern int putenv(
const char *);
156#if defined(R__ARC4_STDLIB)
158#elif defined(R__ARC4_BSDLIB)
159#include <bsd/stdlib.h>
160#elif defined(R__GETRANDOM_CLIB)
161#include <sys/random.h>
166#define STRUCT_UTMP struct utmpx
169#define STRUCT_UTMP struct utmp
171#if !defined(UTMP_FILE) && defined(_PATH_UTMP)
172#define UTMP_FILE _PATH_UTMP
174#if defined(UTMPX_FILE)
176#define UTMP_FILE UTMPX_FILE
179#define UTMP_FILE "/etc/utmp"
183#if (defined(R__LINUX) || defined(R__HURD)) && !defined(R__WINGCC)
184# if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 1
185# define HAVE_BACKTRACE_SYMBOLS_FD
189#if defined(R__MACOSX) || defined(R__FBSD)
190# define HAVE_BACKTRACE_SYMBOLS_FD
194#ifdef HAVE_BACKTRACE_SYMBOLS_FD
195# include <execinfo.h>
204#ifdef HAVE_BACKTRACE_SYMBOLS_FD
211#if (defined(R__LINUX) && !defined(R__WINGCC))
213#include <sys/prctl.h>
216#if defined(R__MACOSX) && defined(__SSE2__)
217#include <xmmintrin.h>
220#if defined(R__MACOSX) && !defined(__SSE2__) && !defined(__xlC__) && \
221 !defined(__i386__) && !defined(__x86_64__) && !defined(__arm__) && \
228#include <mach/thread_status.h>
230#define fegetenvd(x) asm volatile("mffs %0" : "=f" (x));
231#define fesetenvd(x) asm volatile("mtfsf 255,%0" : : "f" (x));
243#if defined(R__MACOSX) && !defined(__SSE2__) && \
244 (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__))
256 template<
typename U = T,
typename std::enable_if<std::is_member_po
inter<decltype(&U::ut_name)>::value,
int>::type = 0>
258 return ue->ut_name[0];
261 template<
typename U = T,
typename std::enable_if<std::is_member_po
inter<decltype(&U::ut_user)>::value,
int>::type = 0>
263 return ue->ut_user[0];
269 return ut_name<STRUCT_UTMP>::getValue(
ue, 0);
348# define HOWMANY(x, y) (((x)+((y)-1))/(y))
410#if defined(R__MACOSX)
412#elif defined(R__LINUX) || defined(R__SOLARIS) || defined(R__FBSD)
418#elif defined(R__SOLARIS)
420#elif defined(R__FBSD)
440 if (
p.BeginsWith(
"/"))
442 else if (
p.Contains(
"/")) {
458#if defined(HAVE_DLADDR) && !defined(R__MACOSX)
472 ::SysError(
"TUnixSystem::SetRootSys",
"error getting realpath of libCore, please set ROOTSYS in the shell");
484#if defined(R__MACOSX)
504 TRegexp sovers =
"libCore\\.[0-9]+\\.*[0-9]*\\.*[0-9]*\\.so";
505 TRegexp dyvers =
"libCore\\.[0-9]+\\.*[0-9]*\\.*[0-9]*\\.dylib";
515 ::SysError(
"TUnixSystem::DylibAdded",
"error getting realpath of libCore, please set ROOTSYS in the shell");
529 if (lib.
EndsWith(
"/libSystem.B.dylib")) {
541 sovers =
"\\.[0-9]+\\.*[0-9]*\\.so";
547 dyvers =
"\\.[0-9]+\\.*[0-9]*\\.dylib";
609#if defined(R__MACOSX)
613#elif defined(HAVE_DLADDR)
672 Warning(
"SetDisplay",
"DISPLAY not set, setting it to %s",
disp.Data());
689 Warning(
"SetDisplay",
"DISPLAY not set, setting it to %s",
697 if (!
gROOT->IsBatch() && !std::getenv(
"DISPLAY")) {
698 Error(
"SetDisplay",
"Can't figure out DISPLAY, set it manually\n"
699 "In case you run a remote ssh session, restart your ssh session with:\n"
700 "=========> ssh -Y");
715#if defined(R__SOLARIS) || defined (R__LINUX) || \
716 defined(R__FBSD) || defined(R__OBSD) || defined(R__HURD)
720 return Form(
"errno out of range %d",
err);
732#if defined(R__SOLARIS)
755 if (
h->HasReadInterest()) {
759 if (
h->HasWriteInterest()) {
772 if (!
h)
return nullptr;
785 int fd =
th->GetFd();
786 if (
th->HasReadInterest()) {
790 if (
th->HasWriteInterest()) {
817 if (!
h)
return nullptr;
828 if (
hs->GetSignal() ==
h->GetSignal())
886#if defined(R__LINUX) && !defined(__powerpc__)
887#if defined(__GLIBC__) && (__GLIBC__>2 || __GLIBC__==2 && __GLIBC_MINOR__>=1)
889#if __GLIBC_MINOR__>=3
914#if defined(R__MACOSX) && defined(__SSE2__)
925#if defined(R__MACOSX) && !defined(__SSE2__) && \
926 (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__))
932#elif defined(__arm64__)
945#if defined(R__MACOSX) && !defined(__SSE2__) && !defined(__xlC__) && \
946 !defined(__i386__) && !defined(__x86_64__) && !defined(__arm__) && \
971#if defined(R__LINUX) && !defined(__powerpc__)
972#if defined(__GLIBC__) && (__GLIBC__>2 || __GLIBC__==2 && __GLIBC_MINOR__>=1)
982#if __GLIBC_MINOR__>=3
1004#if defined(R__MACOSX) && defined(__SSE2__)
1016#if defined(R__MACOSX) && !defined(__SSE2__) && \
1017 (defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__arm64__))
1029#elif defined(__arm64__)
1037#if defined(R__MACOSX) && !defined(__SSE2__) && !defined(__xlC__) && \
1038 !defined(__i386__) && !defined(__x86_64__) && !defined(__arm__) && \
1129 if (
rc < 0 &&
rc != -2) {
1130 SysError(
"DispatchOneEvent",
"select: read error on %d",
fd);
1136 if (
rc < 0 &&
rc != -2) {
1137 SysError(
"DispatchOneEvent",
"select: write error on %d",
fd);
1157 select(0,
nullptr,
nullptr,
nullptr, &
tv);
1179 if (
h->HasReadInterest()) {
1183 if (
h->HasWriteInterest()) {
1187 h->ResetReadyMask();
1226 if (
h->HasReadInterest())
1228 if (
h->HasWriteInterest())
1230 h->ResetReadyMask();
1260 if (
sync ==
sh->IsSync()) {
1291 if (
pty->GetPid() ==
pid) {
1433 return std::string(
cwd);
1442 Error(
"WorkingDirectory",
"getcwd() failed");
1461 if (res)
return std::string(res);
1462 else return std::string();
1497 char *arg =
StrDup(base);
1508 SysError(
"TempFileName",
"converting filedescriptor (%d)",
fd);
1518 if (
name.IsNull() ||
name ==
".") {
1521 if (dir[
strlen(dir) - 1] !=
'/')
1527 if (!dir || !dir[0])
1529 else if (dir[
strlen(dir) - 1] !=
'/')
1611 return helper->IsPathLocal(path);
1652 return ::link(from, to);
1661 return ::symlink(from, to);
1674#if defined(R__SEEK64)
1684 return ::rmdir(
name);
1686 return ::unlink(
name);
1711 const char *
p, *
patbuf = (
const char *)path;
1812 if (ch ==
' ' || ch ==
'\t') {
1846 return ::chmod(file,
mode);
1854 return ::umask(
mask);
1867 t.actime = (time_t)
actime;
1868 t.modtime = (time_t)modtime;
1869 return ::utime(file, &t);
1885 show.Form(
"Which: %s =",
wfil.Data());
1889 if (
wfil[0] ==
'/') {
1890#if defined(R__SEEK64)
1914 for (
const char* ptr =
search; *ptr;) {
1916 if (*ptr !=
'/' && *ptr !=
'$' && *ptr !=
'~')
1927 if (!
name.EndsWith(
"/"))
1932#if defined(R__SEEK64)
1966 return apwd->pw_uid;
2022 ug->fUser =
apwd->pw_name;
2023 ug->fPasswd =
apwd->pw_passwd;
2024 ug->fRealName =
apwd->pw_gecos;
2025 ug->fShell =
apwd->pw_shell;
2027 if (
gr)
ug->fGroup =
gr->fGroup;
2059 gr->fGid =
grp->gr_gid;
2060 gr->fGroup =
grp->gr_name;
2093 return std::getenv(
name);
2127 return ::pclose(
pipe);
2165#include <mach/mach.h>
2189 return ref.csCppData ||
ref.csCppObj;
2211 printf(
"[<unknown binary>]");
2225 printf(
" (no debug info)");
2270 const char *message =
" Generating stack trace...\n";
2272 if (
fd && message) { }
2277#if defined(USE_GDB_STACK_TRACE)
2280 fprintf(
stderr,
"gdb not found, need it for stack trace\n");
2305#elif defined(R__SOLARIS)
2316#elif defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_DLADDR)
2324 const char *
cppfilt =
"c++filt";
2327 const char *
format1 =
" 0x%016lx in %.200s %s 0x%lx from %.200s\n";
2329 const char *
format2 =
" 0x%016lx in %.200s\n";
2331 const char *
format2 =
" 0x%016lx in %.200s at %.200s from %.200s\n";
2333 const char *
format3 =
" 0x%016lx in %.200s from %.200s\n";
2334 const char *
format4 =
" 0x%016lx in <unknown function>\n";
2336 const char *
format1 =
" 0x%08lx in %.200s %s 0x%lx from %.200s\n";
2338 const char *
format2 =
" 0x%08lx in %.200s\n";
2340 const char *
format2 =
" 0x%08lx in %.200s at %.200s from %.200s\n";
2342 const char *
format3 =
" 0x%08lx in %.200s from %.200s\n";
2343 const char *
format4 =
" 0x%08lx in <unknown function>\n";
2355 while (
help.Gets(
p)) {
2359 }
else if (
help.Index(
"gnu-new-abi") !=
kNPOS) {
2369#if (defined(R__LINUX) && !defined(R__WINGCC))
2372#ifdef PR_SET_PTRACER
2409 if (write(
fd, message,
strlen(message)) < 0)
2415 std::ofstream
file1;
2421 Error(
"StackTrace",
"could not open file %s",
tmpf1.Data());
2442 info.dli_sname :
"<unknown>";
2451#if defined(MAC_OS_X_VERSION_10_10)
2453#elif defined(MAC_OS_X_VERSION_10_9)
2526 if (write(
fd,
line.Data(),
line.Length()) < 0)
2537#elif defined(HAVE_EXCPT_H) && defined(HAVE_PDSC_H) && \
2538 defined(HAVE_RLD_INTERFACE_H)
2548 while (!
rc && context.sc_pc) {
2554 const char *
name =
"<unknown function>";
2555 sprintf(buffer,
" 0x%012lx %.200s + 0x%lx\n",
2556 context.sc_pc,
name, context.sc_pc -
addr);
2652 if (
xh->fStdOutTty.IsNull()) {
2655 xh->fStdOutTty =
tty;
2664 if (
xh->fStdErrTty.IsNull()) {
2667 xh->fStdErrTty =
tty;
2672 Warning(
"RedirectOutput",
"could not restore stdout (back to original redirected"
2681 const char *
m = (
mode[0] ==
'a' ||
mode[0] ==
'w') ?
mode :
"a";
2684 xh->fReadOffSet = 0;
2689 xh->fReadOffSet = (
st.fSize > 0) ?
st.fSize :
xh->fReadOffSet;
2707 if (!(
xh->fStdOutTty.IsNull())) {
2712 xh->fStdOutTty =
"";
2716 "problems closing STDOUT_FILENO (%d) before 'dup2' (errno: %d)",
2721 SysError(
"RedirectOutput",
"could not restore stdout (back to original redirected"
2725 if (close(
xh->fStdOutDup) != 0) {
2727 "problems closing temporary 'out' descriptor %d (errno: %d)",
2733 if (!(
xh->fStdErrTty.IsNull())) {
2738 xh->fStdErrTty =
"";
2742 "problems closing STDERR_FILENO (%d) before 'dup2' (errno: %d)",
2747 SysError(
"RedirectOutput",
"could not restore stderr (back to original redirected"
2751 if (close(
xh->fStdErrDup) != 0) {
2753 "problems closing temporary 'err' descriptor %d (errno: %d)",
2798 Error(
"ListSymbols",
"not yet implemented");
2826#if !defined(R__MACOSX)
2832#if defined(R__MACOSX)
2842 if (
dylib.EndsWith(
".dylib") && !
dylib.Contains(
"/libSystem.B.dylib")) {
2853#elif defined(R__LINUX) || defined(R__SOLARIS)
2854#if defined(R__WINGCC )
2855 const char *
cLDD=
"cygcheck";
2856 const char *
cSOEXT=
".dll";
2866 #error "unsupported platform, fix memory leak to use it"
2870 const char *
cLDD=
"ldd";
2871 const char *
cSOEXT=
".so";
2877 while (
ldd.Gets(
p)) {
2894 solib.Remove(idx+3);
2971 if (!
ti)
return nullptr;
3004 hints.ai_socktype = 0;
3005 hints.ai_protocol = 0;
3024 ia.fHostname =
"UnNamedHost";
3027 ia.fHostname =
"UnknownHost";
3049 for (;
rp !=
nullptr;
rp =
rp->ai_next) {
3069 SysError(
"GetSockName",
"getsockname failed");
3074 ia.fFamily =
addr.sa_family;
3081 Error(
"GetSockName",
"getnameinfo failed");
3082 ia.fHostname =
"????";
3099 SysError(
"GetPeerName",
"getpeername failed");
3104 ia.fFamily =
addr.sa_family;
3111 Error(
"GetPeerName",
"getnameinfo failed");
3112 ia.fHostname =
"????";
3127 Error(
"GetServiceByName",
"no service \"%s\" with protocol \"%s\"\n",
3238 SysError(
"AcceptConnection",
"accept");
3251 if (
sock < 0)
return;
3270 int count =
ntohl(header);
3273 Error(
"RecvBuf",
"record header exceeds buffer size");
3275 }
else if (count > 0) {
3277 Error(
"RecvBuf",
"cannot receive buffer");
3295 Error(
"SendBuf",
"cannot send header");
3300 Error(
"SendBuf",
"cannot send buffer");
3342 Error(
"RecvRaw",
"cannot receive buffer");
3377 Error(
"SendRaw",
"cannot send buffer");
3388 if (
sock < 0)
return -1;
3393 SysError(
"SetSockOpt",
"setsockopt(SO_SNDBUF)");
3399 SysError(
"SetSockOpt",
"setsockopt(SO_RCVBUF)");
3405 SysError(
"SetSockOpt",
"setsockopt(SO_OOBINLINE)");
3411 SysError(
"SetSockOpt",
"setsockopt(SO_KEEPALIVE)");
3417 SysError(
"SetSockOpt",
"setsockopt(SO_REUSEADDR)");
3423 SysError(
"SetSockOpt",
"setsockopt(TCP_NODELAY)");
3429 SysError(
"SetSockOpt",
"ioctl(FIONBIO)");
3436 SysError(
"SetSockOpt",
"ioctl(SIOCSPGRP)");
3440 Error(
"SetSockOpt",
"ioctl(SIOCGPGRP) not supported on cygwin/gcc");
3447 Error(
"SetSockOpt",
"illegal option (%d)", opt);
3458 if (
sock < 0)
return -1;
3465 SysError(
"GetSockOpt",
"getsockopt(SO_SNDBUF)");
3471 SysError(
"GetSockOpt",
"getsockopt(SO_RCVBUF)");
3477 SysError(
"GetSockOpt",
"getsockopt(SO_OOBINLINE)");
3483 SysError(
"GetSockOpt",
"getsockopt(SO_KEEPALIVE)");
3489 SysError(
"GetSockOpt",
"getsockopt(SO_REUSEADDR)");
3495 SysError(
"GetSockOpt",
"getsockopt(TCP_NODELAY)");
3502 SysError(
"GetSockOpt",
"fcntl(F_GETFL)");
3508#if !defined(R__LYNXOS) && !defined(R__WINGCC)
3510 SysError(
"GetSockOpt",
"ioctl(SIOCGPGRP)");
3514 Error(
"GetSockOpt",
"ioctl(SIOCGPGRP) not supported on LynxOS and cygwin/gcc");
3519#if !defined(R__LYNXOS)
3521 SysError(
"GetSockOpt",
"ioctl(SIOCATMARK)");
3525 Error(
"GetSockOpt",
"ioctl(SIOCATMARK) not supported on LynxOS");
3530#if !defined(R__LYNXOS)
3532 SysError(
"GetSockOpt",
"ioctl(FIONREAD)");
3536 Error(
"GetSockOpt",
"ioctl(FIONREAD) not supported on LynxOS");
3541 Error(
"GetSockOpt",
"illegal option (%d)", opt);
3562 {
SIGBUS,
nullptr,
nullptr,
"bus error" },
3563 {
SIGSEGV,
nullptr,
nullptr,
"segmentation violation" },
3564 {
SIGSYS,
nullptr,
nullptr,
"bad argument to system call" },
3565 {
SIGPIPE,
nullptr,
nullptr,
"write on a pipe with no one to read it" },
3566 {
SIGILL,
nullptr,
nullptr,
"illegal instruction" },
3567 {
SIGABRT,
nullptr,
nullptr,
"abort" },
3568 {
SIGQUIT,
nullptr,
nullptr,
"quit" },
3569 {
SIGINT,
nullptr,
nullptr,
"interrupt" },
3570 {
SIGWINCH,
nullptr,
nullptr,
"window size change" },
3571 {
SIGALRM,
nullptr,
nullptr,
"alarm clock" },
3572 {
SIGCHLD,
nullptr,
nullptr,
"death of a child" },
3573 {
SIGURG,
nullptr,
nullptr,
"urgent data arrived on an I/O channel" },
3574 {
SIGFPE,
nullptr,
nullptr,
"floating point exception" },
3575 {
SIGTERM,
nullptr,
nullptr,
"termination signal" },
3576 {
SIGUSR1,
nullptr,
nullptr,
"user-defined signal 1" },
3577 {
SIGUSR2,
nullptr,
nullptr,
"user-defined signal 2" }
3635 Break(
"TUnixSystem::DispatchSignals",
"%s: printing stacktrace",
UnixSigname(sig));
3665#elif defined(R__SOLARIS)
3667#elif defined(R__LYNXOS)
3678#if defined(SA_RESTART)
3683 ::SysError(
"TUnixSystem::UnixSignal",
"sigaction");
3702#elif defined(R__SOLARIS)
3710 ::SysError(
"TUnixSystem::UnixIgnoreSignal",
"sigaction");
3713 ::SysError(
"TUnixSystem::UnixIgnoreSignal",
"sigaction");
3732#elif defined(R__SOLARIS)
3734#elif defined(R__LYNXOS)
3746#if defined(SA_INTERRUPT)
3750#if defined(SA_RESTART)
3755 ::SysError(
"TUnixSystem::UnixSigAlarmInterruptsSyscalls",
"sigaction");
3775 ::SysError(
"TUnixSystem::UnixSignal",
"sigaction");
3798 static std::atomic<time_t>
jan95{0};
3810 if ((
int)
jan95 == -1) {
3811 ::SysError(
"TUnixSystem::UnixNow",
"error converting 950001 0:00 to time_t");
3827 itv.it_value.tv_sec = 0;
3828 itv.it_value.tv_usec = 0;
3829 itv.it_interval.tv_sec = 0;
3830 itv.it_interval.tv_usec = 0;
3832 itv.it_value.tv_sec = time_t(ms / 1000);
3833 itv.it_value.tv_usec = time_t((ms % 1000) * 1000);
3837 ::SysError(
"TUnixSystem::UnixSetitimer",
"setitimer");
3911 }
else if (
pw &&
pw->pw_dir) {
3948#if defined(_POSIX_SOURCE)
3951# define REAL_DIR_ENTRY(dp) 1
3953# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
3993#if defined(R__SEEK64)
4002#if defined(R__SEEK64)
4036#if (defined(R__SOLARIS) && !defined(R__LINUX))
4106 if (!
addr.IsValid())
return -1;
4118 ::SysError(
"TUnixSystem::UnixTcpConnect",
"socket (%s:%d)",
4132 ::SysError(
"TUnixSystem::UnixTcpConnect",
"connect (%s:%d)",
4157 if (!
addr.IsValid())
return -1;
4169 ::SysError(
"TUnixSystem::UnixUdpConnect",
"socket (%s:%d)",
4178 ::SysError(
"TUnixSystem::UnixUdpConnect",
"connect (%s:%d)",
4201 ::SysError(
"TUnixSystem::UnixUnixConnect",
"socket path undefined");
4210 ::Error(
"TUnixSystem::UnixUnixConnect",
"socket path %s, longer than max allowed length (%u)",
4218 ::SysError(
"TUnixSystem::UnixUnixConnect",
"socket");
4226 ::SysError(
"TUnixSystem::UnixUnixConnect",
"connect");
4256 ::Error(
"TUnixSystem::UnixTcpService",
"cannot do a port scan while reuse is true");
4268 ::SysError(
"TUnixSystem::UnixTcpService",
"socket");
4289 ::SysError(
"TUnixSystem::UnixTcpService",
"bind");
4301 ::SysError(
"TUnixSystem::UnixTcpService",
"bind (port scan)");
4309 ::SysError(
"TUnixSystem::UnixTcpService",
"listen");
4340 ::SysError(
"TUnixSystem::UnixUdpService",
"socket");
4353 ::SysError(
"TUnixSystem::UnixUdpService",
"bind");
4365 ::SysError(
"TUnixSystem::UnixUdpService",
"bind (port scan)");
4373 ::SysError(
"TUnixSystem::UnixUdpService",
"listen");
4414 ::SysError(
"TUnixSystem::UnixUnixService",
"socket path undefined");
4426 ::Error(
"TUnixSystem::UnixUnixService",
"socket path %s, longer than max allowed length (%u)",
4434 ::SysError(
"TUnixSystem::UnixUnixService",
"socket");
4439 ::SysError(
"TUnixSystem::UnixUnixService",
"bind");
4446 ::SysError(
"TUnixSystem::UnixUnixService",
"listen");
4465 if (
sock < 0)
return -1;
4476 char *
buf = (
char *)buffer;
4513 if (
sock < 0)
return -1;
4522 const char *
buf = (
const char *)buffer;
4559 static std::atomic<bool> initialized(
kFALSE);
4572 initialized =
kTRUE;
4599 if (reset || !initialized) {
4608 #if defined(R__MACOSX)
4633 #if defined(R__WINGCC) || defined(R__MACOSX)
4636 dynpath_syspart +=
"/lib/x86_64-linux-gnu:/usr/local/lib64:/usr/lib64:/lib64:";
4644 const auto ldsyspath = std::getenv(
"ROOT_LDSYSPATH");
4649 std::string
cmd(
"LD_DEBUG=libs LD_PRELOAD=DOESNOTEXIST ls 2>&1");
4654 if (
fgets(buffer, 128,
pf) !=
nullptr)
4658 std::size_t from =
result.find(
"search path=",
result.find(
"(LD_LIBRARY_PATH)"));
4659 std::size_t to =
result.find(
"(system search path)");
4660 if (from != std::string::npos && to != std::string::npos) {
4682 initialized =
kTRUE;
4739 const char* lib =
sLib.Data();
4752 Error(
"FindDynamicLibrary",
4756 static const char*
exts[] = {
4757 ".so",
".dll",
".dylib",
".sl",
".dl",
".a",
nullptr };
4770 Error(
"FindDynamicLibrary",
4771 "%s[.so | .dll | .dylib | .sl | .dl | .a] does not exist in %s",
4788 "hw.realmem dev.cpu.0.freq",
"r");
4807 Error(
"ListSymbols",
"not yet implemented");
4811#if defined(R__MACOSX)
4812#include <sys/resource.h>
4813#include <mach/mach.h>
4814#include <mach/mach_error.h>
4822 "hw.busfrequency hw.l2cachesize hw.memsize",
"r");
4861 ticks[0] = ticks[1] = ticks[2] = ticks[3] = 0;
4883 ::Error(
"TUnixSystem::GetDarwinCpuInfo",
"getloadavg failed");
4978#define vm_region vm_region_64
4982#define GLOBAL_SHARED_TEXT_SEGMENT 0x90000000U
4983#define GLOBAL_SHARED_DATA_SEGMENT 0xA0000000U
4984#define SHARED_TEXT_REGION_SIZE 0x10000000
4985#define SHARED_DATA_REGION_SIZE 0x10000000
4989 ::SysError(
"TUnixSystem::GetDarwinProcInfo",
"getrusage failed");
4992 ((
Float_t)(
ru.ru_utime.tv_usec) / 1000000.);
4994 ((
Float_t)(
ru.ru_stime.tv_usec) / 1000000.);
5017 for (address = 0; ; address +=
size) {
5050 switch (
info.share_mode) {
5052 if (
info.ref_count == 1) {
5074#if defined(R__LINUX)
5110 f =
fopen(
"/proc/meminfo",
"r");
5135 ticks[0] = ticks[1] = ticks[2] = ticks[3] = 0;
5142 sscanf(s.
Data(),
"%*s %ld %ld %ld %ld", &ticks[0], &ticks[3], &ticks[1], &ticks[2]);
5155 ::Error(
"TUnixSystem::GetLinuxCpuInfo",
"getloadavg failed");
5232 ::SysError(
"TUnixSystem::GetLinuxProcInfo",
"getrusage failed");
5235 ((
Float_t)(
ru.ru_utime.tv_usec) / 1000000.);
5237 ((
Float_t)(
ru.ru_stime.tv_usec) / 1000000.);
5262 if (!
info)
return -1;
5267#if defined(R__MACOSX)
5269#elif defined(R__LINUX)
5271#elif defined(R__FBSD)
5288 if (!
info)
return -1;
5290#if defined(R__MACOSX)
5292#elif defined(R__LINUX)
5294#elif defined(R__FBSD)
5307 if (!
info)
return -1;
5309#if defined(R__MACOSX)
5311#elif defined(R__LINUX)
5324 if (!
info)
return -1;
5326#if defined(R__MACOSX)
5328#elif defined(R__LINUX)
The file contains utilities which are foundational and could be used across the core component of ROO...
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
int Int_t
Signed integer 4 bytes (int)
int Ssiz_t
String size (currently int)
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
long long Long64_t
Portable signed long integer 8 bytes.
@ kItimerResolution
interval-timer resolution in ms (used for TThread, TTimer, Emit, Connect, etc.)
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void SysError(const char *location, const char *msgfmt,...)
Use this function in case a system (OS or GUI) related error occurred.
void Break(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
R__EXTERN TExceptionHandler * gExceptionHandler
static unsigned int total
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t org
R__EXTERN TInterpreter * gCling
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
char * StrDup(const char *str)
Duplicate the string str.
int EscChar(const char *src, char *dst, int dstlen, char *specchars, char escchar)
Escape specchars in src with escchar and copy to dst.
@ kSigSegmentationViolation
R__EXTERN const char * gProgName
R__EXTERN TVirtualMutex * gSystemMutex
R__EXTERN const char * gRootDir
ESocketBindOption
Options for binging the sockets created.
@ kInaddrAny
Any address for socket binding.
R__EXTERN TSystem * gSystem
R__EXTERN TFileHandler * gXDisplay
R__EXTERN const char * gProgPath
static void sighandler(int sig)
Call the signal handler associated with the signal.
static const char * DynamicPath(const char *newpath=nullptr, Bool_t reset=kFALSE)
Get shared library search path.
static void SigHandler(ESignals sig)
Unix signal handler.
#define REAL_DIR_ENTRY(dp)
const char * kProtocolName
static struct Signalmap_t gSignalMap[kMAXSIGNALS]
static const char * GetExePath()
void(* SigHandler_t)(ESignals)
#define R__LOCKGUARD2(mutex)
const_iterator begin() const
const_iterator end() const
virtual void HandleException(Int_t sig)
Handle exceptions (kSigBus, kSigSegmentationViolation, kSigIllegalInstruction and kSigFloatingExcepti...
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
virtual void HandleException(int sig)=0
TFdSet & operator=(const TFdSet &rhs)
ULong_t fds_bits[(((kFDSETSIZE)+((kNFDBITS) -1))/(kNFDBITS))]
TFdSet(const TFdSet &org)
virtual Bool_t WriteNotify()
Notify when something can be written to the descriptor associated with this handler.
virtual Bool_t ReadNotify()
Notify when something can be read from the descriptor associated with this handler.
Bool_t Notify() override
Notify when event occurred on descriptor associated with this handler.
This class represents an Internet Protocol (IP) address.
virtual const char * GetSTLIncludePath() const
TObject * Next() override
Return next object in the list. Returns 0 when no more objects in list.
Collectable string class.
virtual const char * GetName() const
Returns name of object.
virtual void SysError(const char *method, const char *msgfmt,...) const
Issue system error message.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Iterator of ordered collection.
TObject * Next() override
Return next object in collection.
Int_t Substitute(TString &s, const TString &replace, const TString &mods="", Int_t start=0, Int_t nMatchMax=10)
Substitute replaces the string s by a new string in which matching patterns are replaced by the repla...
static void ShutDown()
Shut down ROOT.
static const TString & GetEtcDir()
Get the sysconfig directory in the installation. Static utility function.
static const TString & GetLibDir()
Get the library directory in the installation.
Regular expression class.
Int_t Atoi() const
Return integer value of string.
Bool_t Gets(FILE *fp, Bool_t chop=kTRUE)
Read one line from the stream, including the \n, or until EOF.
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Long64_t Atoll() const
Return long long value of string.
Abstract base class defining a generic interface to the underlying Operating System.
virtual void Unload(const char *module)
Unload a shared library.
TSeqCollection * fFileHandler
virtual void AddFileHandler(TFileHandler *fh)
Add a file handler to the list of system file handlers.
TString & GetLastErrorString()
Return the thread local storage for the custom last error message.
virtual Func_t DynFindSymbol(const char *module, const char *entry)
Find specific entry point in specified library.
static void ResetErrno()
Static function resetting system error number.
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
static Int_t GetErrno()
Static function returning system error number.
TFdSet * fReadmask
!Files that should be checked for read events
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
virtual int GetPid()
Get process id.
virtual Long_t NextTimeOut(Bool_t mode)
Time when next timer of mode (synchronous=kTRUE or asynchronous=kFALSE) will time-out (in ms).
virtual int SetSockOpt(int sock, int kind, int val)
Set socket option.
virtual const char * Getenv(const char *env)
Get environment variable.
TFdSet * fWritemask
!Files that should be checked for write events
TFdSet * fSignals
!Signals that were trapped
virtual Bool_t IsPathLocal(const char *path)
Returns TRUE if the url in 'path' points to the local file system.
virtual const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory.
virtual const char * ExpandFileName(const char *fname)
Expand a pathname getting rid of special shell characters like ~.
virtual TFileHandler * RemoveFileHandler(TFileHandler *fh)
Remove a file handler from the list of file handlers.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
virtual void ListLibraries(const char *regexp="")
List the loaded shared libraries.
virtual FILE * OpenPipe(const char *command, const char *mode)
Open a pipe.
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual Bool_t Init()
Initialize the OS interface.
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
TFdSet * fWriteready
!Files with writes waiting
virtual int ClosePipe(FILE *pipe)
Close the pipe.
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
virtual void AddSignalHandler(TSignalHandler *sh)
Add a signal handler to list of system signal handlers.
TSeqCollection * fSignalHandler
TFdSet * fReadready
!Files with reads waiting
TSystem * FindHelper(const char *path, void *dirptr=nullptr)
Create helper TSystem to handle file and directory operations that might be special for remote file a...
std::atomic< Bool_t > fInsideNotify
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
virtual const char * WorkingDirectory()
Return working directory.
virtual char * Which(const char *search, const char *file, EAccessMode mode=kFileExists)
Find location of file in a search path.
virtual TInetAddress GetHostByName(const char *server)
Get Internet Protocol (IP) address of host.
virtual TSignalHandler * RemoveSignalHandler(TSignalHandler *sh)
Remove a signal handler from list of signal handlers.
virtual void Setenv(const char *name, const char *value)
Set environment variable.
static const char * StripOffProto(const char *path, const char *proto)
Strip off protocol string from specified path.
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Basic time type with millisecond precision.
Handles synchronous and a-synchronous timer events.
Bool_t CheckTimer(const TTime &now)
Check if timer timed out.
void AddTimer(TTimer *ti) override
Add timer to list of system timers.
int RecvRaw(int sock, void *buffer, int length, int flag) override
Receive exactly length bytes into buffer.
int OpenConnection(const char *server, int port, int tcpwindowsize=-1, const char *protocol="tcp") override
Open a connection to a service on a server.
int GetMemInfo(MemInfo_t *info) const override
Returns ram and swap memory usage info into the MemInfo_t structure.
Bool_t IsPathLocal(const char *path) override
Returns TRUE if the url in 'path' points to the local file system.
int Symlink(const char *from, const char *to) override
Create a symlink from file1 to file2.
const char * HomeDirectory(const char *userName=nullptr) override
Return the user's home directory.
Int_t GetGid(const char *group=nullptr) override
Returns the group's id. If group = 0, returns current user's group.
static int UnixUdpConnect(const char *hostname, int port)
Creates a UDP socket connection Is called via the TSocket constructor.
int CopyFile(const char *from, const char *to, Bool_t overwrite=kFALSE) override
Copy a file.
TTimer * RemoveTimer(TTimer *ti) override
Remove timer from list of system timers.
int AnnounceUnixService(int port, int backlog) override
Announce unix domain service on path "kServerPath/<port>".
static int UnixTcpConnect(const char *hostname, int port, int tcpwindowsize)
Open a TCP/IP connection to server and connect to a service (i.e.
Int_t SetFPEMask(Int_t mask=kDefaultMask) override
Set which conditions trigger a floating point exception.
static const char * UnixGetdirentry(void *dir)
Returns the next directory entry.
void Setenv(const char *name, const char *value) override
Set environment variable.
int ConnectService(const char *server, int port, int tcpwindowsize, const char *protocol="tcp")
Connect to service servicename on server servername.
Bool_t ChangeDirectory(const char *path) override
Change directory. Returns kTRUE in case of success, kFALSE otherwise.
static int UnixTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize, ESocketBindOption socketBindOption)
Open a socket, bind to it and start listening for TCP/IP connections on the port.
static const char * UnixHomedirectory(const char *user=nullptr)
Returns the user's home directory.
char * GetServiceByPort(int port) override
Get name of internet service.
Bool_t CheckSignals(Bool_t sync)
Check if some signals were raised and call their Notify() member.
static int UnixMakedir(const char *name)
Make a Unix file system directory.
static void UnixSigAlarmInterruptsSyscalls(Bool_t set)
When the argument is true the SIGALRM signal handler is set so that interrupted syscalls will not be ...
Int_t GetFPEMask() override
Return the bitmap of conditions that trigger a floating point exception.
static int UnixUnixConnect(int port)
Connect to a Unix domain socket.
int GetSysInfo(SysInfo_t *info) const override
Returns static system info, like OS type, CPU type, number of CPUs RAM size, etc into the SysInfo_t s...
void Exit(int code, Bool_t mode=kTRUE) override
Exit the application.
void AddDynamicPath(const char *lib) override
Add a new directory to the dynamic path.
void SetDynamicPath(const char *lib) override
Set the dynamic path to a new value.
int ClosePipe(FILE *pipe) override
Close the pipe.
std::string GetHomeDirectory(const char *userName=nullptr) const override
Return the user's home directory.
Int_t Select(TList *active, Long_t timeout) override
Select on file descriptors.
void Unsetenv(const char *name) override
Unset environment variable.
virtual ~TUnixSystem()
Reset to original state.
void Abort(int code=0) override
Abort the application.
void Syslog(ELogLevel level, const char *mess) override
Send mess to syslog daemon.
int AnnounceTcpService(int port, Bool_t reuse, int backlog, int tcpwindowsize=-1, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny) override
Announce TCP/IP service.
UserGroup_t * GetGroupInfo(Int_t gid) override
Returns all group info in the UserGroup_t structure.
Int_t GetUid(const char *user=nullptr) override
Returns the user's id. If user = 0, returns current user's id.
Bool_t ExpandPathName(TString &patbuf) override
Expand a pathname getting rid of special shell characters like ~.
void Openlog(const char *name, Int_t options, ELogFacility facility) override
Open connection to system log daemon.
int AcceptConnection(int sock) override
Accept a connection.
TTime Now() override
Get current time in milliseconds since 0:00 Jan 1 1995.
static void UnixResetSignal(ESignals sig)
Restore old signal handler for specified signal.
int GetServiceByName(const char *service) override
Get port # of internet service.
const char * FindFile(const char *search, TString &file, EAccessMode mode=kFileExists) override
Find location of file "wfil" in a search path.
void SigAlarmInterruptsSyscalls(Bool_t set) override
When the argument is true the SIGALRM signal handler is set so that interrupted syscalls will not be ...
int Utime(const char *file, Long_t modtime, Long_t actime) override
Set a files modification and access times.
const char * GetLinkedLibraries() override
Get list of shared libraries loaded at the start of the executable.
const char * GetError() override
Return system error string.
std::string GetWorkingDirectory() const override
Return working directory.
Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists) override
Returns FALSE if one can access a file using the specified access mode.
FILE * TempFileName(TString &base, const char *dir=nullptr, const char *suffix=nullptr) override
Create a secure temporary file by appending a unique 6 letter string to base.
void DispatchOneEvent(Bool_t pendingOnly=kFALSE) override
Dispatch a single event.
int Chmod(const char *file, UInt_t mode) override
Set the file permission bits. Returns -1 in case or error, 0 otherwise.
const char * PrependPathName(const char *dir, TString &name) override
Concatenate a directory and a file name.
Bool_t DispatchTimers(Bool_t mode)
Handle and dispatch timers.
void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE) override
If ignore is true ignore the specified signal, else restore previous behaviour.
void ListSymbols(const char *module, const char *re="") override
List symbols in a shared library.
int Load(const char *module, const char *entry="", Bool_t system=kFALSE) override
Load a shared library.
void StackTrace() override
Print a stack trace.
TInetAddress GetHostByName(const char *server) override
Get Internet Protocol (IP) address of host.
int SendBuf(int sock, const void *buffer, int length) override
Send a buffer headed by a length indicator.
const char * HostName() override
Return the system's host name.
void CheckChilds()
Check if children have finished.
int RecvBuf(int sock, void *buffer, int length) override
Receive a buffer headed by a length indicator.
static int UnixUnixService(int port, int backlog)
Open a socket, bind to it and start listening for Unix domain connections to it.
UserGroup_t * GetUserInfo(Int_t uid) override
Returns all user info in the UserGroup_t structure.
void SetDisplay() override
Set DISPLAY environment variable based on utmp entry. Only for UNIX.
TFileHandler * RemoveFileHandler(TFileHandler *fh) override
Remove a file handler from the list of file handlers.
static const char * UnixSigname(ESignals sig)
Return the signal name associated with a signal.
static Long64_t UnixNow()
Get current time in milliseconds since 0:00 Jan 1 1995.
static int UnixFSstat(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: id, bsize, bfree, blocks.
void ResetSignals() override
Reset signals handlers to previous behaviour.
TInetAddress GetSockName(int sock) override
Get Internet Protocol (IP) address of host and port #.
int Link(const char *from, const char *to) override
Create a link from file1 to file2.
int GetProcInfo(ProcInfo_t *info) const override
Returns cpu and memory used by this process into the ProcInfo_t structure.
int SetSockOpt(int sock, int option, int val) override
Set socket option.
static int UnixSetitimer(Long_t ms)
Set interval timer to time-out in ms milliseconds.
static int UnixSend(int sock, const void *buf, int len, int flag)
Send exactly length bytes from buffer.
TInetAddress GetPeerName(int sock) override
Get Internet Protocol (IP) address of remote host and port #.
static void UnixIgnoreSignal(ESignals sig, Bool_t ignore)
If ignore is true ignore the specified signal, else restore previous behaviour.
void DispatchSignals(ESignals sig)
Handle and dispatch signals.
void AddFileHandler(TFileHandler *fh) override
Add a file handler to the list of system file handlers.
int AnnounceUdpService(int port, int backlog, ESocketBindOption socketBindOption=ESocketBindOption::kInaddrAny) override
Announce UDP service.
void * OpenDirectory(const char *name) override
Open a Unix file system directory. Returns 0 if directory does not exist.
int Rename(const char *from, const char *to) override
Rename a file. Returns 0 when successful, -1 in case of failure.
const char * Getenv(const char *name) override
Get environment variable.
int GetPathInfo(const char *path, FileStat_t &buf) override
Get info about a file.
Int_t GetEffectiveGid() override
Returns the effective group id.
static int UnixSelect(Int_t nfds, TFdSet *readready, TFdSet *writeready, Long_t timeout)
Wait for events on the file descriptors specified in the readready and writeready masks or for timeou...
int GetPid() override
Get process id.
Int_t Exec(const char *shellcmd) override
Execute a command.
void ResetTimer(TTimer *ti) override
Reset a-sync timer.
TSignalHandler * RemoveSignalHandler(TSignalHandler *sh) override
Remove a signal handler from list of signal handlers.
static void UnixSignal(ESignals sig, SigHandler_t h)
Set a signal handler for a signal.
void CloseConnection(int sock, Bool_t force=kFALSE) override
Close socket.
Bool_t CheckDescriptors()
Check if there is activity on some file descriptors and call their Notify() member.
Bool_t Init() override
Initialize Unix system interface.
void Unload(const char *module) override
Unload a shared library.
int Umask(Int_t mask) override
Set the process file creation mode mask.
static int UnixFilestat(const char *path, FileStat_t &buf)
Get info about a file.
static int UnixRecv(int sock, void *buf, int len, int flag)
Receive exactly length bytes into buffer.
Int_t GetEffectiveUid() override
Returns the effective user id.
void FillWithCwd(char *cwd) const
Fill buffer with current working directory.
static int UnixWaitchild()
Wait till child is finished.
int Unlink(const char *name) override
Unlink, i.e.
void ListLibraries(const char *regexp="") override
List all loaded shared libraries.
void Closelog() override
Close connection to system log daemon.
Int_t RedirectOutput(const char *name, const char *mode="a", RedirectHandle_t *h=nullptr) override
Redirect standard output (stdout, stderr) to the specified file.
void Sleep(UInt_t milliSec) override
Sleep milliSec milliseconds.
void ResetSignal(ESignals sig, Bool_t reset=kTRUE) override
If reset is true reset the signal handler for the specified signal to the default handler,...
const char * TempDirectory() const override
Return a user configured or systemwide directory to create temporary files in.
Func_t DynFindSymbol(const char *module, const char *entry) override
dynamic linking of module
const char * GetDynamicPath() override
Return the dynamic path (used to find shared libraries).
FILE * OpenPipe(const char *shellcmd, const char *mode) override
Open a pipe.
void FreeDirectory(void *dirp) override
Close a Unix file system directory.
static void UnixResetSignals()
Restore old signal handlers.
int GetCpuInfo(CpuInfo_t *info, Int_t sampleTime=1000) const override
Returns cpu load average and load info into the CpuInfo_t structure.
void AddSignalHandler(TSignalHandler *sh) override
Add a signal handler to list of system signal handlers.
static void * UnixOpendir(const char *name)
Open a directory.
int SendRaw(int sock, const void *buffer, int length, int flag) override
Send exactly length bytes from buffer.
const char * WorkingDirectory() override
Return working directory.
int GetSockOpt(int sock, int option, int *val) override
Get socket option.
const char * FindDynamicLibrary(TString &lib, Bool_t quiet=kFALSE) override
Returns the path of a shared library (searches for library in the shared library search path).
void SetProgname(const char *name) override
Set the application name (from command line, argv[0]) and copy it in gProgName.
const char * GetDirEntry(void *dirp) override
Get next Unix file system directory entry. Returns 0 if no more entries.
int MakeDirectory(const char *name) override
Make a Unix file system directory.
static int UnixUdpService(int port, int backlog, ESocketBindOption socketBindOption)
Open a socket, bind to it and start listening for UDP connections on the port.
int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree) override
Get info about a file system: id, bsize, bfree, blocks.
const std::string & GetFallbackRootSys()
const char * GetExePath()
Returns the executable path name, used e.g. by SetRootSys().
struct sigaction * fOldHandler
struct utmp * fUtmpContents
struct utmp * SearchUtmpEntry(const char *tty)