/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: 2009-02-05 03:15:43 UTC
  • Revision ID: teddy@fukt.bsnet.se-20090205031543-cyd3j09i6iut38w1
* plugin-runner.c (struct plugin.status): Changed type to "int".
  (main): Check "proc->completed" before "proc->eof", since
          "completed" is of type "sig_atomic_t".

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
  size_t buffer_size;
90
90
  size_t buffer_length;
91
91
  bool eof;
92
 
  volatile bool completed;
93
 
  volatile int status;
 
92
  volatile sig_atomic_t completed;
 
93
  int status;
94
94
  struct plugin *next;
95
95
} plugin;
96
96
 
120
120
    }
121
121
  }
122
122
  
123
 
  *new_plugin = (plugin) { .name = copy_name,
124
 
                           .argc = 1,
125
 
                           .disabled = false,
126
 
                           .next = plugin_list };
 
123
  *new_plugin = (plugin){ .name = copy_name,
 
124
                          .argc = 1,
 
125
                          .disabled = false,
 
126
                          .next = plugin_list };
127
127
  
128
128
  new_plugin->argv = malloc(sizeof(char *) * 2);
129
129
  if(new_plugin->argv == NULL){
232
232
      break;
233
233
    }
234
234
    if(pid == -1){
235
 
      if(errno != ECHILD){
236
 
        perror("waitpid");
 
235
      if(errno == ECHILD){
 
236
        /* No child processes */
 
237
        break;
237
238
      }
238
 
      /* No child processes */
239
 
      break;
 
239
      perror("waitpid");
240
240
    }
241
241
    
242
242
    /* A child exited, find it in process_list */
248
248
      continue;
249
249
    }
250
250
    proc->status = status;
251
 
    proc->completed = true;
 
251
    proc->completed = 1;
252
252
  }
253
253
}
254
254
 
376
376
  };
377
377
  
378
378
  error_t parse_opt(int key, char *arg, __attribute__((unused))
379
 
                    struct argp_state *state) {
380
 
    switch(key) {
 
379
                    struct argp_state *state){
 
380
    switch(key){
381
381
    case 'g':                   /* --global-options */
382
382
      if(arg != NULL){
383
383
        char *p;
512
512
     ignores everything but the --config-file option. */
513
513
  error_t parse_opt_config_file(int key, char *arg,
514
514
                                __attribute__((unused))
515
 
                                struct argp_state *state) {
516
 
    switch(key) {
 
515
                                struct argp_state *state){
 
516
    switch(key){
517
517
    case 'g':                   /* --global-options */
518
518
    case 'G':                   /* --global-env */
519
519
    case 'o':                   /* --options-for */
959
959
       from one of them */
960
960
    for(plugin *proc = plugin_list; proc != NULL;){
961
961
      /* Is this process completely done? */
962
 
      if(proc->eof and proc->completed){
 
962
      if(proc->completed and proc->eof){
963
963
        /* Only accept the plugin output if it exited cleanly */
964
964
        if(not WIFEXITED(proc->status)
965
965
           or WEXITSTATUS(proc->status) != 0){
970
970
              fprintf(stderr, "Plugin %" PRIdMAX " exited with status"
971
971
                      " %d\n", (intmax_t) (proc->pid),
972
972
                      WEXITSTATUS(proc->status));
973
 
            } else if(WIFSIGNALED(proc->status)) {
 
973
            } else if(WIFSIGNALED(proc->status)){
974
974
              fprintf(stderr, "Plugin %" PRIdMAX " killed by signal"
975
975
                      " %d\n", (intmax_t) (proc->pid),
976
976
                      WTERMSIG(proc->status));