示例#1
0
文件: err.c 项目: jhbsz/DIR-850L_A1
int err_setlogfile(char *file) {
    char *mode;
    int result=TRUE;

/*
    if(strcmp(file,err_filename) == 0)
        return TRUE;
*/

    if(err_file) {
        io_close(err_file);
    } else {
        err_file = io_new();
        if(!err_file) {
            err_logdest &= ~LOGDEST_LOGFILE;
            if(!err_syslog_open)
                os_opensyslog();
            os_syslog(1,"Error initializing logfile");
        }
    }

    mode = "a";
    if(err_truncate) mode = "w";

    strncpy(err_filename,file,sizeof(err_filename)-1);

    if(!io_open(err_file,"file://%U?mode=%s&ascii=1",err_filename,mode)) {
        fprintf(stderr,"Error opening logfile: %s",io_errstr(err_file));
        err_logdest &= ~LOGDEST_LOGFILE;

        if(!err_syslog_open)
            os_opensyslog();
        os_syslog(1,"Error opening logfile");

        result=FALSE;
    }

    return result;
}
示例#2
0
/**
 * Check whether Admind is running.
 */
static void check_admind(void)
{
#ifndef WITH_SUPSIM
    /* We can't use os_daemon_status() here because it is implemented with
     * waitpid(): a process P can use waitpid() on a process P' *iff* P' is
     * a child of P, and Admind is not a child of Csupd!
     *
     * We use os_daemon_exists() which may return a false positive if the
     * specified daemon is zombie, but Admind can't be zombie since it is
     * reparented to init and init will reap it.
     */
    if (!os_daemon_exists(admind_daemon))
    {
        const char *name = exa_daemon_name(EXA_DAEMON_ADMIND);
        os_syslog(OS_SYSLOG_ERROR, "daemon %s (pid %"PRIu32") is dead => EXITING",
                  name, admind_pid);
        exit(1);
    }
#endif
}