In a C software I try to open a file (ROOT file in Cern Castor) through XROOTD using XrdPosix_Open in a forked process using the same binary as the father process. However the open hang, a priori because it does not get an answer from the XRootd threads which belong to the father process. I put below an example in C which reproduces the problem. I open a XROOTD file in the father process without problem, but when I try to read a similar file in the child process it hangs. The backtrace returned by gdb on the child process is the following (it's the only thread present): #0 0x00007ffff6e8268c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #1 0x00007ffff70bf9ec in XrdSysCondVar::Wait() () from /usr/lib64/libXrdUtils.so.2 #2 0x00007ffff73a51e8 in XrdCl::File::Open(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, XrdCl::OpenFlags::Flags, XrdCl::Access::Mode, unsigned short) () from /usr/lib64/libXrdCl.so.2 #3 0x00007ffff7bd1d6e in XrdPosixXrootd::Open(char const*, int, unsigned int, XrdPosixCallBack*) () from /usr/lib64/libXrdPosix.so.2 #4 0x00007ffff79b2506 in XrdPosix_Open () from /usr/lib64/libXrdPosixPreload.so.1 #5 0x0000000000400a04 in main () at tstxrootd.c:38 Is there a way to be able to open a XROOTD file in a forked process ? Or a workaround available ? The XRootd version used is the 4.8.5 (the one available on lxplus stations at Cern). Thanks for your help ! Here is the piece of C code: #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> #include <errno.h> #include <fcntl.h> #include <time.h> #include <string.h> #include <XrdPosix/XrdPosix.hh> char fname1[]="root://castorpublic.cern.ch//castor/cern.ch/compass/data/2016/oracle_dst/P11/slot2/mDST/mDST-276407-2-7.root.001"; char fname2[]="root://castorpublic.cern.ch//castor/cern.ch/compass/data/2016/oracle_dst/P11/slot2/mDST/mDST-276407-2-7.root.002"; struct stat statbuf; int stret, retcode, fd1, fd2; main () { stret = XrdPosix_Stat(fname1, &statbuf); fprintf(stderr, "stat filename %s, ret %d, uid %d size %lld atime %s mode 0%lo \n", fname1, stret, statbuf.st_uid, (long long) statbuf.st_size, ctime(&statbuf.st_atime),statbuf.st_mode) ; stret = XrdPosix_Stat(fname2, &statbuf); fprintf(stderr, "stat filename %s, ret %d, uid %d size %lld atime %s mode 0%lo \n", fname2, stret, statbuf.st_uid, (long long) statbuf.st_size, ctime(&statbuf.st_atime),statbuf.st_mode) ; sleep(2); if ( (retcode = fork()) == 0 ) { /* child */ sleep(20); fprintf(stderr, "In child\n"); fd1 = XrdPosix_Open(fname1, O_RDONLY); /* the child process hangs here */ fprintf(stderr, "Child: xrootd file opened %s, fd %d, errno %d %s\n", fname1, fd1, errno, strerror(errno)); sleep(1); XrdPosix_Close(fd1); fprintf(stderr, "Child: xrootd file closed\n"); sleep(10000); } else { /* father */ fprintf(stderr, "In father\n"); fd2 = XrdPosix_Open(fname2, O_RDONLY); /* the father process is ok to open the file */ fprintf(stderr, "Father: xrootd file opened %s, fd %d, errno %d %s\n", fname2, fd2, errno, strerror(errno)); sleep(1); XrdPosix_Close(fd2); fprintf(stderr, "Father: xrootd file closed\n"); sleep(10000); } fprintf(stderr, "End of program\n"); } -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/xrootd/xrootd/issues/897 ######################################################################## Use REPLY-ALL to reply to list To unsubscribe from the XROOTD-DEV list, click the following link: https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1