Linking ROOT libraries is causing signal

Hi,

the following short programs (which does not use ROOT at all!) reproduces the issue:

#include <iostream>
#include <stdio.h>
#include <unistd.h>

int main(){

  int pid = fork();

  if ( pid==0 ) {

    execlp("sleep", "sleep", "1", NULL );

  }
  else {

    for (unsigned int i=0; i< 20; i++){

      std::cout<<i*0.1<<" sec"<<std::endl;

      if ( usleep( 100000 ) ) {

          perror("usleep");

      }

    }

  }

}

When compiled without root ( g++ main.cpp) it runs just fine. When linked with root ( g++ main.cpp root-config --libs ) it gives an error ( usleep: Interrupted system call ) which indicates that the usleep in the parent received a signal after about 1s (when the child terminated).

Why does linking this program with ROOT change the behaviour? For me this looks very strange and I’d be happy to know what’s going on.

I’m using the following versions of g++ and root on lxplus:

/afs/cern.ch/sw/lcg/contrib/gcc/4.7.2p1/x86_64-slc6-gcc47-opt/bin/g++
/afs/cern.ch/sw/lcg/app/releases/ROOT/5.34.14/x86_64-slc6-gcc47-opt/root/bin/root

Thanks in advance,
Bjorn

Hi,

any ideas on this one? For an even more minimal example - the following function with two lines is enough to reproduce it:

[code]#include <stdio.h>
#include <unistd.h>

int main(){

if ( !fork() ) execlp(“sleep”, “sleep”, “1”, NULL );
else if ( sleep( 2 ) ) perror(“sleep”);

}
[/code]
It doesn’t matter which ROOT library is linked, e.g just -lCore or -lTree is enough to get the error message “sleep: Interrupted system call”

Cheers,
Bjorn