title: Daemon not reactiing
body: <p>I've already asked a similar question a few days ago. Basically I have to make a daemon-client communicate via named tubes. The client part is done and sends messages correctly, but the daemon part seems to not be receiving anything... Here's the code:</p>
  <pre><code>void makeDaemon(){
    int i,fd0,fd1,fd2;
    pid_t pid;
    struct sigaction sa;
    struct rlimit rl;
  
    umask(0);
  
    if(getrlimit(RLIMIT_NOFILE, &amp;rl)&lt;0) exit(EXIT_FAILURE); 
  
    if((pid=fork())&lt;0) exit(EXIT_FAILURE);
    if(pid&gt;0) exit(EXIT_SUCCESS);
  
    setsid();
  
    sa.sa_handler=SIG_IGN;
    sigemptyset(&amp;sa.sa_mask);
    sa.sa_flags=0;
  
    if(sigaction(SIGHUP, &amp;sa, NULL)&lt;0) exit(EXIT_FAILURE);
  
    if((pid=fork())&lt;0) exit(EXIT_FAILURE);
    if(pid&gt;0) exit(EXIT_SUCCESS);
  
    //if(chdir(&quot;/&quot;)&lt;0) exit(EXIT_FAILURE);
  
    if(rl.rlim_max=RLIM_INFINITY) rl.rlim_max=1024;
    for(i=0;i&lt; rl.rlim_max; i++) close(i);
  
    close(STDIN_FILENO);
    close(STDOUT_FILENO);
    close(STDERR_FILENO);
  
    //sigaction(SIGUSR1,&amp;sac,NULL);
  }
  
  int main(){
    makeDaemon();
  
    char* path=&quot;./run/pipes/saturnd-request-pipe&quot;;
    char* path2=&quot;./run/pipes/saturnd-reply-pipe&quot;;
  
    //Creation d'un pipe au cas où il n'existe pas
    //mkfireply_pipe(path,0666);
    int timeout=5000;
    struct pollfd pf[1];
      
    int request_pipe;
    
  
    while(1){
      request_pipe=open(path,O_RDONLY);
      if(request_pipe==-1){
          perror(&quot;Erreur d'ouverture du pipe&quot;);
          exit(EXIT_FAILURE);
      }
  
      pf[0].fd=request_pipe;
      pf[0].events=POLLIN;
  
      int p=poll(pf,1,timeout);
        
      if(pf[0].revents &amp; POLLIN){
        char tmp1[2];
        ssize_t s=read(request_pipe,tmp1,2);
         if(s==-1) exit(EXIT_FAILURE);
         printf(&quot;%s\n&quot;,tmp1);
         int i=1;
      }else{
        printf(&quot;Timed out\n&quot;);
        break;
      }
      return 0;
    }
  }
  </code></pre>
  <p>My question is, should I maybe make a handler containing this while loop so that the daemon can receive a signal? As of right now, it just times out and dies. We cannot use sockets, and everything is done via these two names pipes. Any suggestion would be appreciated. Thanks!</p>