XRootD
Loading...
Searching...
No Matches
XrdWait41.cc File Reference
#include <cctype>
#include <dirent.h>
#include <fcntl.h>
#include <signal.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <strings.h>
#include <unistd.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "XrdOuc/XrdOucTList.hh"
#include "XrdSys/XrdSysE2T.hh"
#include "XrdSys/XrdSysHeaders.hh"
#include "XrdSys/XrdSysPlatform.hh"
#include "XrdSys/XrdSysPthread.hh"
+ Include dependency graph for XrdWait41.cc:

Go to the source code of this file.

Classes

class  XrdW41Dirs
 
class  XrdW41Gate
 

Namespaces

namespace  XrdWait41
 

Functions

void * XrdWait41::GateWait (void *parg)
 
int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 116 of file XrdWait41.cc.

117{
118 sigset_t myset;
119 XrdOucTList *gateFiles = 0;
120 struct stat Stat;
121 const char *eText;
122 char buff[8];
123 int i;
124
125// Turn off sigpipe and host a variety of others before we start any threads
126//
127 signal(SIGPIPE, SIG_IGN); // Solaris optimization
128 sigemptyset(&myset);
129 sigaddset(&myset, SIGPIPE);
130 sigaddset(&myset, SIGCHLD);
131 pthread_sigmask(SIG_BLOCK, &myset, NULL);
132
133// Set the default stack size here
134//
135 if (sizeof(long) > 4) XrdSysThread::setStackSize((size_t)1048576);
136 else XrdSysThread::setStackSize((size_t)786432);
137
138// Construct a list of files. For each directory, expand that to a list
139//
140 for (i = 1; i < argc; i++)
141 {if (stat(argv[i], &Stat))
142 {eText = XrdSysE2T(errno);
143 std::cerr <<"wait41: " <<eText <<" processing " <<argv[i] <<std::endl;
144 continue;
145 }
146 if (S_ISREG(Stat.st_mode))
147 gateFiles = new XrdOucTList(argv[i],0,gateFiles);
148 else if (S_ISDIR(Stat.st_mode))
149 gateFiles = XrdW41Dirs::Expand(argv[i], gateFiles);
150 }
151
152// If we have no waiters then fail
153//
154 if (!gateFiles)
155 {std::cerr <<"wait41: Nothing to wait on!" <<std::endl;
156 std::cout <<"BAD\n" <<std::endl;
157 _exit(1);
158 }
159
160// Now wait for the first lock
161//
162 eText = (XrdW41Gate::Wait41(gateFiles) ? "OK\n" : "BAD\n");
163 std::cout <<eText <<std::endl;
164
165// Now wait for the process to die
166//
167 if (read(STDIN_FILENO, buff, sizeof(buff))) {}
168 exit(0);
169}
struct stat Stat
Definition XrdCks.cc:49
#define stat(a, b)
Definition XrdPosix.hh:96
#define read(a, b, c)
Definition XrdPosix.hh:77
const char * XrdSysE2T(int errcode)
Definition XrdSysE2T.cc:104
static void setStackSize(size_t stsz, bool force=false)
static XrdOucTList * Expand(const char *Path, XrdOucTList *ptl)
Definition XrdWait41.cc:178
static int Wait41(XrdOucTList *fP)
Definition XrdWait41.cc:259

References XrdW41Dirs::Expand(), read, XrdSysThread::setStackSize(), Stat, stat, XrdW41Gate::Wait41(), and XrdSysE2T().

+ Here is the call graph for this function: