/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to plugin-runner.c

  • Committer: Teddy Hogeborn
  • Date: 2014-06-14 02:55:24 UTC
  • Revision ID: teddy@recompile.se-20140614025524-k03150tjp4t89w1d
plugin-runner: Restore resources correctly if fork() fails.

* plugin-runner.c (main): If fork() fails, close pipe FD's and restore
                          signal mask for SIGCHLD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
985
985
    ret = set_cloexec_flag(pipefd[0]);
986
986
    if(ret < 0){
987
987
      error(0, errno, "set_cloexec_flag");
 
988
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
989
      TEMP_FAILURE_RETRY(close(pipefd[1]));
988
990
      exitstatus = EX_OSERR;
989
991
      goto fallback;
990
992
    }
991
993
    ret = set_cloexec_flag(pipefd[1]);
992
994
    if(ret < 0){
993
995
      error(0, errno, "set_cloexec_flag");
 
996
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
997
      TEMP_FAILURE_RETRY(close(pipefd[1]));
994
998
      exitstatus = EX_OSERR;
995
999
      goto fallback;
996
1000
    }
1010
1014
    } while(pid == -1 and errno == EINTR);
1011
1015
    if(pid == -1){
1012
1016
      error(0, errno, "fork");
 
1017
      TEMP_FAILURE_RETRY(sigprocmask(SIG_UNBLOCK,
 
1018
                                     &sigchld_action.sa_mask, NULL));
 
1019
      TEMP_FAILURE_RETRY(close(pipefd[0]));
 
1020
      TEMP_FAILURE_RETRY(close(pipefd[1]));
1013
1021
      exitstatus = EX_OSERR;
1014
1022
      goto fallback;
1015
1023
    }