let open_files =
  let opened = ref false in
  let openlog f =
    Unix.openfile
      ((Ocsiconfig.get_logdir ())^"/"^f)
      [Unix.O_WRONLYUnix.O_CREATUnix.O_APPEND] 0o640
  in
  fun () ->
    if !opened
    then begin
      Unix.close !(snd access);
      Unix.close !(snd warningfile);
      Unix.close !(snd error)
    end;
    opened := true;
    snd access := openlog (fst access);
    snd warningfile := openlog (fst warningfile);
    snd error := openlog (fst error);
    Unix.set_close_on_exec !(snd access);
    Unix.set_close_on_exec !(snd warningfile);
    Unix.set_close_on_exec !(snd error)